Revision: 55606
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 14, 2012 05:11 by tcelestino
Initial Code
function paglink($first=1,$last=1,$middle=10,$baseURL=false,$wp_query=false ) { if(!$baseURL) $baseURL= get_bloginfo('url'); if(!$wp_query)global $wp_query; $page = $wp_query->query_vars["paged"]; if ( !$page ) $page = 1; $qs = $_SERVER["QUERY_STRING"] ? "?".$_SERVER["QUERY_STRING"] : ""; if ( $wp_query->found_posts > $wp_query->query_vars["posts_per_page"] ) { echo '<div class="box-paginacao">'; if ( $page > 1 ) { echo '<a href="'.$baseURL.(($page==2)?('page/'.($page-1).'/'):'').$qs.'" class="link-anterior">anterior</a>'; } else { echo '<div class="link-anterior-sem">anterior</div>'; } $dots=false; echo '<div class="paginas">'; for ( $i=1; $i <= $wp_query->max_num_pages; $i++ ){ // Loop through pages if($i<=$first || $i<=$middle && $page<$middle || $i>$wp_query->max_num_pages-$last || $i>$wp_query->max_num_pages-$middle && $page>$wp_query->max_num_pages-$middle+1 || $i>$page-ceil($middle/2) && $i<=$page+floor($middle/2)){ if ( $i == $page ) { // Current page or linked page? echo '<strong>'.$i.'</strong>'; } else { echo '<a href="'.$baseURL.(($i!=1)?('page/'.$i.'/'):'').$qs.'">'.$i.'</a>'; } $dots=false; }elseif(!$dots){ echo '<span>...</span>'; $dots=true; } } echo '</div>'; if ( $page < $wp_query->max_num_pages ) { // Next link? echo '<a href="'.$baseURL.'page/'.($page+1).'/'.$qs.'" class="link-proximo">próximo</a>'; } else { echo '<div class="link-proximo-sem">próximo</div>'; } echo '</div>'; } } //use function paglink(1, 1, 10, get_bloginfo('wpurl').'/your_post_type_or_categories/', $wp_query);
Initial URL
Initial Description
I dont remember the author this code.
Initial Title
Pagination WordPress without plugin
Initial Tags
wordpress
Initial Language
HTML