Pagination Alteration
-
I poked into the code:
in includes\shortcodes\posts.php
(ca. line 250)
– I added a reference to $paged.
– I added a reference to that in the args:$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; $args = array( 'category_name' => '', 'order' => $order, 'orderby' => $orderby, 'post_type' => explode( ',', $post_type ), 'posts_per_page' => $posts_per_page, 'paged' => $paged, 'tag' => $tag, );
To leave the code as close to the baseline as possible, I put in code to carry out the pagination:
function su_pager($query, $total_page) { global $paged; $paging = ""; // do the pagination if(function_exists('wp_pagenavi')) { $paging .='<div class="page-navigation">'.wp_pagenavi(array('query' => $query, 'echo' => false)).'</div>'; } else { $paging .=' <span class="next-posts-links">'.get_next_posts_link('>', $total_page).'</span> <span class="prev-posts-links">'.get_previous_posts_link('<').'</span> '; } return $paging; }
In the loops:
// Posts are found if ( $posts->have_posts() ) { $posts_per_page = 10; $total_found_posts = $posts->found_posts; $total_page = ceil($posts / $posts_per_page); while ( $posts->have_posts() ) {
… custom code….
`}
print ‘</ul>’;
print su_pager($posts, $total_page);
}
// Posts not found
else {
?>
<li><?php _e( ‘Nothing found’, ‘shortcodes-ultimate’ ) ?></li>
</ul>
<?php
}
?>`
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Pagination Alteration’ is closed to new replies.