How to add pagination for wordpress home page

I needed something similar on my blog too. I used the following code to add the necessary links (adjust as required) <?php previous_posts_link(__( ‘<button class=”btn btn-primary pull-left”><i class=”fa fa-long-arrow-left”></i>&nbsp; Newer Posts</button>’ )) ?> <?php next_posts_link(__( ‘<button class=”btn btn-primary pull-right”>Older Posts &nbsp;<i class=”fa fa-long-arrow-right”></i></button>’ )) ?>

i want to add pagination list of categories

<?php $args = array( ‘parent’ => 0, ‘hide_empty’ => 0 ); $categories = get_categories( $args ); echo $cat = ceil(count( $categories )/5); ?> <?php $j=0; $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $posts_per_page = 5; $offset = ($posts_per_page * $paged) – 5 ; $args = array( ‘orderby’ => ‘name’, ‘parent’ => 0, ‘hide_empty’ => 0, … Read more

Pagination Not Working Properly

IF you a using a query post make sure to add if ( get_query_var(‘paged’) ) { $paged = get_query_var(‘paged’); } elseif ( get_query_var(‘page’) ) { $paged = get_query_var(‘page’); } else { $paged = 1; } query_posts( ‘post_type=yourposttype&paged=’.$paged); above script will correct the dead links on wordpress pagination.

Pagination Error – Same Posts Displaying Over Again

<?php query_posts(‘offset=1′); ?> This is your problem. The pagination functions work off of the main query, but you replace the main query at the start of every page, and the only thing you’ve told it is that the offset is 1, how is it supposed to know you wanted page 2?! So instead, I’m going … Read more

Show pagination in WP_Query

This is the pagination function I use. I’m not sure if the github link is the original credit, but its one i found. Add the following to your functions.php file: /** * Creates Custom Pagination * @link https://gist.github.com/rgfx/755cfb71fd1732e4e7b7bdcbd4b6e4e3 * @param string $numpages Show pagination in WP_Query * @param string $pagerange Show pagination in WP_Query * … Read more

pagination leads to 404 page

After an exhausted effort of a whole day finally find the solution. i write these two functions in my functions.php file and finally i got the expected result. function remove_page_from_query_string($query_string) { if ($query_string[‘name’] == ‘page’ && isset($query_string[‘page’])) { unset($query_string[‘name’]); // ‘page’ in the query_string looks like ‘/2’, so i’m spliting it out list($delim, $page_index) = … Read more