First of all you need to get the paged query variable and pass it to your main query args:
//Protect against arbitrary paged values
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$args = array(
'post_type' => 'post'
'paged' => $paged,
);
Then you have to add the following code at the place where you want the pagination to appear:
<?php
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $post_query->max_num_pages
) );
?>
Related Posts:
- Home page not obeying post per page setting on the first page only
- Why does pagination go to a blank page when navigating through home.php?
- Pagination 404s on custom query
- Blog pagination WITHOUT using max_num_pages
- Only show pagination when post count exceeds show post
- Pagination not working on blog grid
- paged query leads to 404? [duplicate]
- WordPress /page/2 404 pagination problem – what to do?
- how to get pagination link url?
- add_rewrite_rule – working fine but broken for pagination
- How can I see all of a post’s comments on a single page as a reader, if pagination is enabled?
- Check if on last page of paginated post using wp_link_pages
- How to paginate a list of tags
- How do I sort multiples pages?
- WordPress pagination on custom script
- Broken pagination
- pagenavigation not showing the next page just linking back to the main page [closed]
- Paginate get related post by author function
- How to use pre_get_posts?
- Keep Pagination in Tabs
- Need help understanding pagination parameters
- redirect pages with no content, instead of 404 error, using max_num_posts?
- WordPress API returns empty page when page is less than X-WP-TotalPages
- Custom query in archive.php with pagination nightmare
- Display only the current page number and another numbered page in pagination
- Display post links under month in paginated archive
- Pagination (page/2/) displaying 404 on archive pages
- How to use “offset” to paginate get_users?
- How to test pagination? [closed]
- Limited number of paging to 10 “pages: 1 … 10”
- remove_query_arg() on rewrite rule
- Hide featured post on second page
- I cannot get pagination to work on my home page code. it keeps displaying the same posts
- Pagination url canonical problem
- Fetching more posts in WordPress via AJAX
- AJAX pagination offset returns same post on adjacent pages
- 404 on pagination but with a strange twist (error 404 only when there is single post on the second page)
- Add additional first page, last page links to the_posts_pagination()
- wp_title() returns ‘page not found’ on page 2
- Homepage has Paged Pages that should not exist, like /page/2/ and on to /page/99999/
- Randomised Post Time
- WordPress paginate_links() function doesn’t generate properly links after apply filters
- Not refreshing content pagination on search result
- rewrite url with parameter or pagination beyond certain value does not work
- stop pretty pagination rewrite site.com/cat/2 => site.com/cat?page=2
- How checked checkboxes remember on all pages in wp_list_table pagination?
- Update to 4.4.1 breaks my pagination
- Issue on single.php pagination WordPress
- Pagination on home page not working
- How to set up pagination [closed]
- WordPress triggers 404 on page 2 for custom search query
- Search page pagination does not work
- Custom wp_link_pages for paginated posts | Next page randomly
- How to ignore pagebreaks for RSS feed?
- Custom pagination code is not working
- Why won’t pagination work?
- Pagination doesnt show numbers
- where is wordpress search pagination
- Problem with older entries in homepage
- How do I override all theme pagination throughout a site?
- Translating a pager string
- Pagination, query more pages at once
- Paginate_links only working on first page
- Pagination for previous page/next page (with more than one post/page)
- What is the best way to implement ajax based pagination on custom query based templates?
- Pagination for custom post types
- Custom post type pagination like “previous current/all next”
- what code to add to search.php
- remove rel=next on category page (if
- Setting up Pagination with twentytwelve_content_nav
- GoBlog Free Pagination Issue
- Show number of pagination pages even when total under two
- Why next_posts(); function does not work inside header.php?
- Pagination inside the blog page not working
- I would like to fix a problem with post pagination: i can only see the url title (prev – next) but title is truncated
- Override the WordPress default pagination markup
- Pagination with Metaboxes or Custom Fields
- The pagination is working on Local, not on LIVE. why?
- 2 Columns with Independent Pagination
- Prevent WordPress to remove query vars from url
- Google Indexed sub pages in wordpress pagination in post
- Paginate Links function: Page 1 doesn’t work
- Pagination doesn’t work on static front page
- Changing post per page causing 404 for pagination. Need a redirect htaccess rule
- How to display most viewed posts without any plugins
- Search engine not working
- Split a long form into multiple pages
- Pagination options using xml data instead of database?
- Infinite scroll repeats posts in custom loop in single.php
- One post on frontpage and an archive page
- pagination for blog landing page
- Pagination is not working correctly there is this wierd looping
- Pagination Error – Same Posts Displaying Over Again
- margins in between pagination links [closed]
- Page navigation not working correctly on index but only on categories
- How to split long posts in multiple pages in twentysixteen
- Duplicating pagination on second page
- Separate page for pagination possible?
- Why does WordPress keep directing or forcing my pagination?
- Search pagination rewrite to fix 404