I believe the query var that you are retrieving should be paged
and not page
. See the codex and adjust your query to the following:
$products_query = new WP_Query(array(
'post_type' => 'product',
'posts_per_page' => 4,
'paged' => (get_query_var('paged') ? get_query_var('paged') : 1),
));
However, if this is an archive for your product post type why not use archive-product.php and let WP handle the query and pagination automatically? See template hierarchy.
Related Posts:
- Multiple WP_Query loops with Pagination
- Pagination returns 404 after page 20
- Pagination with WP_Query is buggy – working for some pages, but not the others
- Get the number of posts from the current page results
- Pagination with 5 posts per page
- Pagination/infinite scroll with WP_Query and multiple loops
- Pagination Not working on Home Page with 2 Query
- Display different number of posts from one category on the different pages
- Pagination not working Search posts
- Transient pagination not working properly
- Injecting content with $wp_query->current_post restarts from zero on paged pages. How to inject content after X posts, regardless of pagination?
- Woocommerce custom loop to show all the products [closed]
- How to bring specific post to front of wordpress loop?
- Pagination stops at page 6
- Paginated HTML Sitemap
- Multiple WP_Query loops with Pagination Not Working
- Posts loop with pagination on a single post page
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
- Pagination is broken and I need help fixing it
- Storing query variable and then using wp_reset_query
- Create A Loop With A Variable Number of Posts For Each Bootstrap Row?
- Five posts from a category in footer
- posts_per_page not working for first page of pagination
- How do I get my custom query to work with search results after the first page?
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Second loop pagination changes URL, not content
- I am officially missing something about transient posts
- Query Not working as expected
- Paginate pages with dynamic query
- Function the_posts_pagination() not compatible with WP_Query arguments
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- Pagination inside the blog page not working
- Custom Query Pagination not working on static front page
- Paging works correctly on local version, but not live?
- Problem with custom WP_Query and underlying pagination/posts_per_page
- 2 Loops on one page – pagination of 2nd loop ignore array of excluded posts
- Pagination returns 404 after page 20
- custom query – offset to pagination
- Pagination not working with WP_QUERY
- No content found on page 2 of pagination with 1 post per page
- wp_query pagination links producing 404
- Loop being strainge
- Multiple loops on index page with sticky post and pagination
- Pagination problem with multiple loops on the same page
- WordPress Post Looping? [duplicate]
- Show number of posts AND number on current page (cannot make it work)
- Pagination only showed when no category is set in wp_query
- Some doubts about how the main query and the custom query works in this custom theme?
- Loop within a loop?
- Merging a complex query with post_rewind and splitting posts into two columns
- meta_query not working properly
- Best Practice For Querying Grandchildren?
- Two queries on the same page with pagination
- Query sticky posts with thumbnails
- Show all parents and children in custom post type in right order
- Why is this coming back as null? Thats wrong. There is one post
- Ignore post by meta value in the main query
- Pagination working everywhere but the index page
- How to retrieve current page WP_Query arguments?
- Random loop with code to prevent duplicate output returns no output at all from time to time
- How to use offset in WP_Query
- How to set pagination to work with ‘/page/’?
- Multiple loops without repeating content
- WP_Query Pagination on multiple-loop page breaks WP or doesn’t show up
- Pagination links missing for first link (1) and previous button? How to get pagination links to work?
- How to return a 404 when custom query matches nothing?
- Multisite pagination issue by multi query archive 404
- different for loop if screen resolution < 1000px
- Transient api Caches confused
- Append URL query to next post link in custom query
- Pagination is not working with custom query inside a homepage template
- Display single most recent post in category on every page of category archive
- sort and display posts by custom field (wp-query and the loop))
- inserting content of 1 Post to in another with a template hierarchy
- Pagination for custom loop on custom page template is not displaying anything
- Writing less unnecessary code with WordPress
- Filter subpages in while loop from WP Query object
- How to filter a static post page with ajax and $wp_query
- Use have_posts() with array of post results retrieved by $wpdb->get_results
- Custom query does not find pages
- How to sort by most watched in X days/months
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Reciving Error 404 blog/page/2/
- How can I use arrays and a foreach to generate many lists with WP_Query?
- wordpress pagination wont render on custom page template even though its right under the loop like the documentation says so
- How to use custom page for all posts with custom url, call another directory?
- display ACF repater field in archive page
- Pagination repeating posts on search results
- WP_Query breaking the loop in a nested loop
- update_post_meta() not updating
- WordPress pagination not returning posts on second page
- why default wordpress loop not working outside index.php
- Can’t get pagination to work with this WP_Query loop
- paginate_links() with Custom Taxonomy
- WordPress post pagination on custom template not working
- Can’t seem to get an else statement correct? [closed]
- Output ACF field dynamicaly within a taxonomy loop [closed]
- How do I split a large query with a semi-expensive function included into multiple smaller queries
- Search results stuck on page 1
- taxonomy-{term}.php terms pagination returning 404 after a certain page