WordPress doesn’t automatically add all query string params ($_GET params) as query_var
s.
When Query Var somevar
is not registered:
example.com/some-page/?somevar=hello
– WordPress ignores somevar
When Query Var somevar
is registered:
example.com/some-page/?somevar=hello
– WordPress stores the value of this param in the $wp_query->query_vars array
The difference between registering that variable with WordPress is whether the value is stored in the WP_Query object.. (it should still be available via $_GET regardless).
To register your custom query var, you should use:
add_filter('query_vars', 'add_my_var');
function add_my_var($public_query_vars) {
$public_query_vars[] = 'some_unique_identifier_for_your_var';
return $public_query_vars;
}
Also look out not to use default WordPress query_var names – you’ll probably get some conflicts then, I guess.
Related Posts:
- paginate_links ignore my format
- Find out total number of pages in global query on archive page?
- Multiple WP_Query loops with Pagination
- WordPress Pagination Not Working – Always Showing First Pages Content
- get_query_var( ‘paged’ ) not working outside of homepage
- 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
- WP_Query and Pagination on a Static front page
- Why does pagination always break when used on any form of a home page?
- Pagination shows 404 after a certain number of pages
- Custom permalink with pagination
- Pagination/infinite scroll with WP_Query and multiple loops
- Pagination broken when merging search results with additional WP_Query
- WP_query and pagination?
- pagenavi with merged wp_query [duplicate]
- Query with pre_get_posts to get pagination
- 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]
- Determine WP_Query parameters from URL
- How to bring specific post to front of wordpress loop?
- Merged two WP_Queries, posts per page and pagination not working
- Pagination 404 errors for author posts query on author.php
- Why query_vars get altered in WP_Query Object?
- Pagination problem after WP_Query with tag filtering
- Pagination stops at page 6
- Paginated HTML Sitemap
- 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
- Rewrite rule to prettify two $_GET variables while in a new endpoint from a page
- WP Pagination on Posts Search Results Page resulting from AJAX WP Query
- Create A Loop With A Variable Number of Posts For Each Bootstrap Row?
- Five posts from a category in footer
- The pagination on index.php doesn’t work on a first page
- paging in WP_Query on static page
- pagination with numbers for WP_User_Query
- WordPress pagination not working using WP_Query
- posts_per_page not working for first page of pagination
- Cutom wp_query for geolocation search, pagination not working
- Pagination inside of a edit page
- WP Query to have sticky posts first, with pagination and having a joint ‘posts per page’ arg with main loop
- How to get a query variable?
- Pagination on static Posts page
- how to access query string in wordpress?
- How do I get my custom query to work with search results after the first page?
- How to cache wp_query with pagination using transients?
- Query Vars Not Set in Main Query
- Pagination only won’t work in author template
- Removing duplicate values between two wordpress queries
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Pagination on template page for custom query redirecting to index.php
- Query_vars support in Rest API
- Yoast primary category query modification
- Pagination in html table is not working
- Paging + WP Query
- WP_Query custom order and pagination
- Unable to paginate a custom page query
- Query Not working as expected
- WP_query paged pagination with excluded category still counts it
- max_num_pages says 4, yet I am only able to navigate to the third page
- Paginate pages with dynamic query
- filter posts by meta key with pagination
- Determining what post is displayed out of total posts found
- Trouble Making WP_Query paged
- Ajax (jquery) wp_query pagination returns -1
- Function the_posts_pagination() not compatible with WP_Query arguments
- paginate_links appearing on page but it doesn’t actually paginate – pagination on a static page with a dynamic `post_type` argument on a static page
- Pagination of custom page with custom fields query
- pre_get_posts pagination not working
- Pagination not working on archive.php template?
- WordPress Sub Category Archive, Show Extra Empty Page Number in Pagination
- Pagination unique to a widget
- Why pagination is not working with tax_query param?
- paginate_links method doesn’t show second page of my custom wp_query
- Wp_Query Post per page not working?
- Pagination Shows Up But Won’t Work on Custom Gallery Page
- Custom Query Pagination not working on static front page
- WordPress search page pagination displaying but not functional
- Paginated Post List on Front Page
- Combine WP_Query with array of custom data to single loop without breaking the pagination
- Pagination returns 404 after page 20
- WP_Query with Pagination and orderby meta_value_num showing duplicates
- Archive – Show Page Month Headers
- Query post Pagination Problem
- Pagination for custom query throws 404 errors on last pages [duplicate]
- Horizontally paginate through sets of blog posts?
- Pagination error WordPress multiple loop
- Comments orderby comment date not working
- Switched from query_posts to wp_query, pagination no longer working
- Pagination With Custom WP Query not functioning
- Ordering Custom WP_Query loop by meta key value with pagination
- Query specific number of posts for each post type in specific order
- Custom query (author is post_author or meta co_author) with Pagenavi pagination
- paginate_links() on page (shortcode output)
- WordPress Post Looping? [duplicate]
- Pagination showing same posts despite changing page
- error with $query->have_posts()
- Pagenavi with archive page