category.php
is the main category archive template file, which is auto-magically loaded by WordPress for category archives. In that case, use the pre_get_posts
hook to alter the main query for this page and you shouldn’t have trouble with the pagination.
function pregp_wpse_100602($qry) {
if (is_category() && is_main_query()) {
// no idea what conditions you want, but below is a sample
// $qry->set('posts_per_page',5);
}
}
add_action('pre_get_posts','pregp_wpse_100602');
As is, you’ve created a second loop– $loop->
— for the page. The pagination functions do not work well when you do that. Those functions depend on the main query, which you are not using. I believe that is the root of the problem.
Related
WordPress pagination on custom script
https://wordpress.stackexchange.com/a/77545/21376
Related Posts:
- Paginate Link generate additional #038; whenever my Url have multiple Query String
- WordPress Pagination Problem
- paginate_links and query vars
- How to edit or override a Core function?
- Add css class to Pagination?
- Highlight the first page pagination_links
- paginate_links URL
- How to focus to a specific div when page reloads by pagination?
- Why does paginate_links() reload the entire page? and can you make it reload only a specific div?
- How to use multiple paginate_links() in my index.php?
- bones_page_navi and pre_get_posts Action
- paginate_links adds strong element
- How to break the wp_link_pages in two lines
- Changing pagination list class
- paginate_links() don’t properly work in search.php?
- Paginate links with “ugly” and “pretty” permalinks?
- Strange paginate_links behavior. First page link is always whatever page I’m on, all other links are correct
- How to paginate attachments in a secondary query as gallery?
- Custom Search Page Pagination Not Working
- Pagination Not Displaying on Custom Term Archive
- Combining WordPress pagination functions for archives and search results
- Paginated pages are showing correct content but pagination links are not
- How to change URL structure for pagination pages?
- Search – Ajax – Alter Query Parameters with Pagination
- Edit format of Paginate_Links()
- paginate_links() outputs extra empty pages on custom loop
- Paginate_links won’t create the right links on a taxonomy filtered custom post type archive
- In pagination, change link for page 1 to homepage
- Can paginate_links() be customized for a specific category or tag?
- WP_QUERY loop, offset in the arguments and the paginate_links – can these work together?
- Paginate_links links not working accordingly to how I do query the page
- Custom post type archive page pagination
- Unable to get paginate_links working with a custom query [duplicate]
- Customizing comments pagination for bootstrap
- 404 on term taxonomy archive pagination only with some terms
- get_the_content_feed with paginated posts
- Last page in pagination does not match max_num_pages – the overall post count is less according to pagination
- How to get URL for the first page of post archive
- Why category.php throw 404 in wordpress while calling paginate_links()?
- How do you paginate a query grouped by month?
- get_next_posts_link not working without parameter max_num_pages
- Duplicate posts in paginated results
- Invalid previous pagination links generated from paginate_links()
- Pretty urls for custom pagination
- pagination for single post by category
- paginate_links() don’t properly work in search.php?
- Limiting number of visible links displayed with wp_link_pages
- search with pagination not working as expected
- Pagination Not Working on `WP_Query` Archive Page
- Include a leading zero in pagination
- Pagination Links showing incorrect previous page number
- Pagination using paginate_links
- Later blog post pages give 404 error
- Custom admin page pagination permissions error
- Paginate Links – Mid Size Less Than 2
- paginate_links() Change the order of links
- Paginate_links only working on first page
- Give wp link pages it’s own template
- Pagination on WP_User_Query not updating current page
- Automatically adding a link to the next page link before ” tag in posts?
- How to add pagination to category templates
- On click some element i want to use some template
- Pagination not working on custom post types with rewrite slug
- How to Show Next-Previous Link Only
- Archive page for WordPress Custom Post Type doesn’t show pagination from paginate_links()
- Pagination contents not changing in Front page WordPress
- How to add pagination in Terms
- Can’t Add Pagination
- paginate_links method doesn’t show second page of my custom wp_query
- Sidebar pagination posts not shown when sidebar is in single.php
- Broken pagination links on WP 4.9.10 blog pages
- How to add post page pagination to template part?
- 404 page not found on pagination in home page while navigating to next page
- I want to create pagination for my custom post type archive that i am displaying with loop
- Post navigation doesn’t show (in custom template, custom post type, custom query)
- Paginate nested query of child posts
- Extra pagination pages being wrongly generated
- Google Indexed sub pages in wordpress pagination in post
- Paginate Links function: Page 1 doesn’t work
- Removin /page/2 from pagination
- Disable pagination on frontpage
- Paginating custom posts in categories yields a 404 error
- WordPress 404 pagination (/page/2) error?
- Paginating custom query on category template
- WordPress Pagination Not Working After Transfer from Localhost
- Add Custom Pagination Permalink
- How can I get my pagination to recognize that it is on the first page?
- How to change page location in WordPress
- Custom pagination [duplicate]
- Wp Pagenavi how to display all results
- Paginate Links not working
- Why is my pagination showing up?
- Pagination not working for archive
- Default pagination in Home/Front page
- wp_link_pages return value even when is condition inside if statement
- error with $query->have_posts()
- Pagination only working on index page not on a template page
- Wrong rewrite rules
- Two pagination in one page without AJAX
- Pagination only showed when no category is set in wp_query