You use your custom WP_Query
to query posts, but then in pagination you use global $wp_query
variable, which contains different query.
You should use your custom query variable $works
in your pagination, or change global $wp_query
variable before your pagination function call.
Since you use universal function to output pagination, second method will be better/easier. Do it like this:
global $wp_query;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$works = new WP_Query('category_name=work&posts_per_page=9&paged=' . $paged);
$original_query = $wp_query; // store original query for later use
$wp_query = $works; // overwrite it with your custom query
... your code
... your pagination code
$wp_query = $original_query; // restore original query
Related Posts:
- Changing pagination list class
- Paged posts – how to use numbers and next/previous links?
- 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
- Pagination Not Displaying on Custom Term Archive
- Combining WordPress pagination functions for archives and search results
- In pagination, change link for page 1 to homepage
- Last page in pagination does not match max_num_pages – the overall post count is less according to pagination
- Invalid previous pagination links generated from paginate_links()
- Using Ajax in the prev_posts_link and next_posts_link
- 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
- Custom admin page pagination permissions error
- Paginate Links – Mid Size Less Than 2
- Paginate_links only working on first page
- 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
- How to Show Next-Previous Link Only
- Show number of pagination pages even when total under two
- Can’t Add Pagination
- 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
- The pagination is working on Local, not on LIVE. why?
- Paginate Links in Wp Query Shortcode
- Extra pagination pages being wrongly generated
- Google Indexed sub pages in wordpress pagination in post
- Paginate Links function: Page 1 doesn’t work
- Disable pagination on frontpage
- Paginating custom posts in categories yields a 404 error
- WordPress 404 pagination (/page/2) error?
- How can I get my pagination to recognize that it is on the first page?
- Default pagination in Home/Front page
- Pagination only working on index page not on a template page
- Pagination Broken on Loop using ACF
- WordPress /page/2 404 pagination problem – what to do?
- how to get pagination link url?
- add_rewrite_rule – working fine but broken for pagination
- Getting paginate_links() ‘end_size’ to display none
- Check if on last page of paginated post using wp_link_pages
- 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
- Keep Pagination in Tabs
- I want to change the media list with additionally query
- Content only on last page, if the page has pagination
- WordPress API returns empty page when page is less than X-WP-TotalPages
- How can I paginate image attachments in a post?
- Pagination shows same contents all pages
- Link to previous month’s posts
- How to get “last year from [spec year] that has posts”?
- Pagination url canonical problem
- WordPress loading index page instead of archive.php
- How can I paginate a list of related posts?
- tag.php pagination and query_posts()
- Add icons in paginate_links()
- How can I use var php with javascript to build custom page? [closed]
- WordPress single page template, custom post type, pagination orderby title – alphabetical order
- Category lists page foreach Paging
- Issue on single.php pagination WordPress
- Adding range to wp_link_pages()
- How to set up pagination [closed]
- Pagination 404s on custom query
- Customise wp_List_pages to output a UL LI
- Custom wp_link_pages for paginated posts | Next page randomly
- Pagination in home page for a custom loop loads same content
- Pagination not working with custom post type
- Displaying the author of next and previous posts in pagination?
- How to ignore pagebreaks for RSS feed?
- Pagination doesn’t function properly for archive of a custom post type set as the front page
- Pagination For Table Rows on a page?
- Universal CPT archive template and half working pagination
- Problem with older entries in homepage
- WP Page Navi. 404 error when using posts per page parameter [duplicate]
- Pagination in author, category, archive and tags pages does not work
- WordPress pagination with wp_query_columns
- How can I paginate results from get_children
- Setting up Pagination with twentytwelve_content_nav
- Why can i add /page/674874 (or any number) to a URL and it still pulls up that page?
- How to add numbers pagination to this blog page?
- Why next_posts(); function does not work inside header.php?
- Override the WordPress default pagination markup
- Pagination with Metaboxes or Custom Fields
- Prevent WordPress to remove query vars from url
- Output wp_link_pages as raw url
- Search engine not working
- Custom pagination [duplicate]
- 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?