How to add query parameters to all internal links?

I’m trying to add url query parameters to all internal links inside a WordPress blog. For example, client lands on the blog with this link: www.example.com/?p1=test&p2=test I want the links inside the blog, for example a link to a post, to still have the query strings: www.example.com/post1/?p1=test&p2=test Is there is a way to do it? … Read more

I can’t fetch query parameters ($_GET parameters) with get_query_var

I am developing pagination for a list of posts in my plugin. I’ve added a custom parameter in my plugin_functions.php file: add_query_arg(‘pworkspage’, 1); As you can see it defaults to “1”. Now, whenever I visit the custom admin page of my plugin with that parameter in the URL (www.example.com/wp-admin/admin.php?page=mycustompage&pworkspage=2) my script can’t see the parameter … Read more

Custom query_var causes displaying posts archive on front page

I’m having an issue which is caused by custom query var named date I’ve added using query_vars hook. When date parameter is present in the front page URL (https://example.com/?date=23.08.2016), WordPress is loading posts archive instead of just front page. When other random params are added to the link (https://example.com/?foo=bar) or no params are present, front … Read more

Filtered query_vars becomes global. Why does this work?

For some reason that’s not quite clear, when I add custom query_vars, they become available everywhere without the need of an accessor like global or get_query_var() // if your url contains the var http://example.com?document_id=99 // and you add it to $query_vars… <?php function filter__query_vars( $query_vars ) { $query_vars[] = ‘document_id’; return $query_vars; } add_filter( ‘query_vars’, … Read more

paginate_links ignore my format

I need the pagination liks to have the url, like: current_url?p-page=1 current_url?p-page=2 current_url?p-page=3 And so.. The reason I need this is because I have other params in the page. the problem is that in the docs, it specs: format (string) (optional) Used for Pagination structure. The default value is ‘?page=%#%’, If using pretty permalinks this … Read more

How to correctly escape query variables to be used in WP_Query

I’ve got custom query variables that are added via query_vars. For example, ‘industry’. In pre_get_posts action I construct and add taxonomy query if there is a value for the ‘industry’ parameter, like so: add_action( ‘pre_get_posts’, ‘alter_posts’); function alter_posts( $q ) { $tax_query = array(); // industry taxonomy if ( get_query_var( ‘industry’ ) ) { $tax_query[] … Read more