Corrigindo paginação para loops personalizados no WordPress
Por: jvitor
sáb
17
mar
2012
Categorias
WordPress
Tags
17
mar
2012
Olá pessoal,
Passei por um problema recorrente nos meus sites quanto a paginação em loops personalizados.
Adicione a função curPageURL() no seu functions.php
//Função para corrigir paginação com erro function curPageURL() { preg_match('/page/(?P<page>d+)/', $_SERVER["REQUEST_URI"], $matches); return $matches['page']; } //add the protocol $pageURL .= "://"; //check what port we are on if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } //cut off everything on the URL except the last 3 characters $urlEnd = substr($pageURL, -3); //strip off the two forward shashes $page = str_replace("/", "", $urlEnd); //return just the number return $page;
Com a função adicionada execute a query_post( ) como no exemplo:
//add in the catagory and page number query_posts('cat=7,8,12,13,15&paged='.curPageURL());
Pronto! Espero que ajude.
Paz