Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [query-variable]

The tag has no usage guidance.

0
votes
0answers
24 views

Changing WP_Query params with url Query Var

:) I've used WP_Query to display there posts (travels) here http://boost19.delavec.si/wordpressP/produkti/ So... I've got this WP_Query that is looping through my custom posts <?php $paged = (...
0
votes
1answer
18 views

How to unset a set query variable?

My theme file, multiple times over, passes sets a variable to a template part used in a subsequent template part file via set_query_var, like so... set_query_var('feature_id', array(143866)); ...
0
votes
1answer
15 views

Rewrite query var on postname

I'm trying to do a rewrite, so that the query var is going to look pretty: This is the URL structure I got now: example.com/post-type-archive/post-name/?subpage=about This is what I want: example....
0
votes
1answer
20 views

Custom permalink question

I have a multisite environment where I am switching databases to retrieve data in a custom post type entered on one site to show on the other site. On the site where the data is not stored (and the ...
0
votes
1answer
18 views

Why does a header location on admin_head remove the query var I'm setting in the location?

I have the following code which I thought would load the location with a query var of saved=1. public function __construct() { add_action( 'admin_head', array( $this, 'test' ) ); } public ...
0
votes
2answers
27 views

Wordpress pass url to page template when page does not exist

I created a page template to serve information dynamically. For url like example.com/the-hamptons => index.php?page_id=92&filter=the-hamptons For url like example.com/page-that-exists <- ...
0
votes
1answer
34 views

How to include a query_vars value in document_title_parts?

I have a page template, used on a single page, which takes URL string parameters like this... http://www.example.com/mypage?tags=Publishing Facilitated like this... // Inherit the meta target ...
0
votes
1answer
28 views

How to call code when adding WooCommerce menu items via woocommerce_account_menu_items

I'm inserting menu items similar to the code example at https://wordpress.stackexchange.com/a/277080/137417, but I haven't encountered endpoints before and the documentation and tutorial I've looked ...
0
votes
0answers
30 views

use query var argument as verification link?

In a from response email I want to send a link to with a unique url string attached to it. Clicking that link and visiting the website through that link should trigger a function. The way I thought to ...
0
votes
1answer
35 views

Trying to Create a PHP Variable for post_type that can be referenced Site Wide

I have several sites with several custom PHP widget loops I've created. I would like to reuse these widgets in other areas and site, but with different custom post types. The only unique thing in ...
1
vote
0answers
26 views

Redirect Uploads Folder to Query Vars in WordPress

I'm looking to redirect pdfs documents from the uploads folder to WordPress to prevent unauthorized site visitors from viewing them. I have used the code provided from this thread How to restrict ...
0
votes
0answers
48 views

Custom Fields Query Vars and Rewrite not working

i have a problem with query vars and rewrite rules. I have - a page called "luoghi" - one custom field called "test_city" - a query var called "city" Into "luoghi" page i did the query with custom ...
0
votes
1answer
230 views

how to access query string in wordpress?

There are several ways I have seen this question worded, so I tried to make mine generic. Let's say I go to this page: example.com/page/?utm_source=test&s=test&page=12 get_query_var('...
3
votes
1answer
252 views

Custom permalink with pagination

I have a custom post type called news and in order to distinguish current and old news posts I have a custom field where the client can mark a news post as 'archived'. So my permalink rewrite code ...
1
vote
0answers
152 views

Custom taxonomy rewrite with query var returns %2F in URL

I'm facing a (hopefully) small issue right now I can't seem to solve. First of all my page is set up in a way that all my projects (custom post type) are displayed on one big page with a query var ...
1
vote
2answers
1k views

Enqueue Script with URL parameters

I have the following I'm trying to enqueue in functions.php wp_enqueue_script( 'param-example', 'https://domain.com/example?f=j&s=w&c=t', array(), null ); Except WordPress is escaping the ...
0
votes
0answers
31 views

CPT year wise archive based on custom date Field

I am trying to group( archive ) my CPT (fcra_donation : has_archive => true) based on a custom date Field ( sukritham-donation-date : format yyyymmdd (20160506). Here is my code in my functions.php ...
3
votes
1answer
1k views

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 ...
0
votes
1answer
29 views

Get list of all Topics in use by a custom post type

I have a custom post type that has an option to tag that post as part of a 'Topic'. This is set in the taxonomy: register_taxonomy( 'topic', array('post','blog','shows'), array( '...
1
vote
1answer
276 views

how to add rewrite rule to wordpress default post type

hello trying to add rewrite rule to default post type with this add_action('init', 'add_my_rewrite'); function add_my_rewrite() { global $wp_rewrite; $wp_rewrite->add_rule('(.*)/server/([^/...
0
votes
0answers
1k views

add_filter('query_vars') not working in custom template

I'm trying to add a query parameter to a custom template in order to look up a record from the DB with the ID passed in. Here's how I'm attempting to do it: At the very top of my custom template, I ...
0
votes
1answer
119 views

Prevent WordPress to remove query vars from url

I have a website and in my localhost I can access page pagination through query_vars. However, when I upload this site to my server, it does not recognize query_vars and simply removes it from the URL....
1
vote
0answers
317 views

Get query parameters from external url and make a redirection

assuming that I have been redirected from an external API, to my front page website, and in the current url there is some query parameter provided by that API, how can I get those parameters and make ...
0
votes
1answer
172 views

Force Rewrite Query Var On Hierarchical (Nested) Page

I want to use a hierarchical (nested) page with a query var to pull dynamic content. I had things working when the page wasn't a child of another page, such as: mysite.com/my-page/1234-my-var/ ...
5
votes
1answer
437 views

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 ...
0
votes
0answers
83 views

WP CLI - Pass Query / URL Variable to Cron?

Is there a way to pass URL / Query variables when you run: wp cron event run using WP CLI? I have a specific event and ID I want to pass to it but don't know if it is possible or how to pass GET ($...
0
votes
0answers
154 views

Own query vars are not displayed

I'm trying to write a custom rewrite rule and then to a redirect based on the last part of it: add_filter('query_vars', 'a_add_query_vars'); add_action('init', 'a_rewrite_tags'); add_action('init', '...
2
votes
3answers
1k views

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 ...
1
vote
0answers
581 views

set_query_var doesn't seem to work on init hook

Based on the trick of using set_query_var with get_template_part to easily pass variables from one template file to another (see here: Method 3), I thought I could use the same method for passing ...
1
vote
1answer
270 views

get_query_var returns wrong default value

I want to make my custom terms to be sortable by users. I've created different links to let the user decide how they want to sort it. <a href="?orderby=name&order=asc" data-target="#">Name ...
3
votes
2answers
2k views

add_rewrite_rule not working for page var

I have a page called mypage and a custom query var called mycustomvar, I am trying to rewrite the following url: http://example.com/index.php?name=mypage&mycustomvar=someword to http://example....
0
votes
1answer
29 views

Taxonomy Rewrite Problem

I have actor and genre taxonomies. add_action('init','ap_url_redirect_rules'); add_filter('query_vars', 'ap_register_query_vars'); function ap_url_redirect_rules(){ add_rewrite_rule('([^/]+)?$', ...
0
votes
1answer
51 views

Change default query parameters

Hi I am using an exteral site which redirects to my wordpress site with some url parameters. Unfortunately one of these is m which is causing a conflict which wordpress's native parameters and ...
3
votes
1answer
227 views

How to Modify Existing Rewrite Rules?

I'm attempting to modify existing rewrite rules generated by WordPress in order to override the default rewrite rules generated. I'm using the filter hook rewrite_rules_array to obtain an array of ...
0
votes
1answer
386 views

Pretty Filter URL

I'm developing an calender. It works very well for. My last point on the list is "make the url pretty". Currently I have a page (example.com/my-calendar/) with a custom php-template which renders the ...
0
votes
1answer
34 views

Single Post (CPT) in two pages - Normal and Extended

How can I make a post (Post_type) have an extended view in a different page? What I want to do is the same thing that this site does with "read more" and the URL of the post. A working example would ...
0
votes
1answer
884 views

Redirect old query string URLs to new add_rewrite_rule URL

I have a custom page like this: website.com/show/?id=9999&n=show-name /show/ is a WordPress page with a postid of 540. I added a rewrite rule to convert the URL to: website.com/show/9999/show-...
1
vote
1answer
97 views

get_query_var not working for subdirectory

I am using this code $pagename = get_query_var('pagename'); to get page name. Its working fine on localhost install under root directory. But when I have moved wordpress to run under subdirectory it ...
0
votes
0answers
70 views

How to redirect a query string to a “virtual” subdirectory

Is it possible to redirect: example.com/?language=en to example.com/en/ and example.com/page/?language=en to example.com/en/page/ If so, how would it be accomplished?
0
votes
1answer
268 views

Last query_var not working with rewritten URL

I am trying to get custom URLs to load a specific template page, and I am mostly there, but my last query_var in the string refuses to load. Here is what is in my functions file: function ...
1
vote
1answer
1k views

query_vars filter not working even though query string parameter is present

I am adding a new query string parameter to be passed into the URL so that I can manipulate the REST API responses. I added this to my functions.php add_filter('query_vars', function ($vars) { ...
1
vote
2answers
1k views

Variable in Array Not Working

I having an issue getting a variable to work for one of my arguments in a query. I am using a custom post type and category name as terms to determine which categories are displayed. When I hardcode ...
1
vote
1answer
119 views

Custom query var rewriting with only variable

On every post there is a "read" (default) and "listen" button that users can click on without page refresh. The listen tab can be accessed directly through domain.com/category/post-title/?listen=...
0
votes
1answer
370 views

How to pass a query string to another page on the same site?

I am using a plugin that uses unique user ids (uuid) to let visitors access some information. They receive this information by email. This works great, if the visitor opens the direct page with a url ...
3
votes
1answer
475 views

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), ...
0
votes
2answers
315 views

How to use endpoint, but remove/rewrite endpoint base?

I've been messing around with rewrites and query_var to generate some listings, for example: ~/my-page/?my_var=1 ~/my-page/?my_var=2 ~/my-page/?my_var=3 After perusing StackExchange and the ...
1
vote
0answers
157 views

add_rewrite_rule permalinks break in WordPress 4.5

I have a plugin that uses permalinks to deliver content to the page based on an activity that I pass in through the URL, eg. mysite.com/activity/11. I also have code in my plugin that redirects the ...
3
votes
0answers
135 views

Change Theme from Plugin based on query_vars

I'm working from about 4 months on developing a Plugin. This plugin make in a page an entire app, using the powerful of Wordpress. So, I've decided to create a serires of rewrite rules using command ...
-2
votes
1answer
821 views

query_vars category_name only display one catgory out of multiple categories

I am working on a plugin which alter the query arguments! Plugin uses $wp_query->query_vars['category_name'] to get the category slugs. Everything works when I am fetching posts from one category. ...
3
votes
1answer
2k views

Passing Variable as URL Parameter — Security concerns?

I need to make sure I'm not opening up a security hole in my site. I have a Custom Post Type called "Communities" and a custom post type called "Floor Plans" and need to add a parameter to the URL on ...