Questions tagged [query-variable]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
11 views

How can I get custom post types to recognize pretty permalink variables?

I'm using PODS to create a custom post type called "automobile" on my site. This results in a permalink structure that looks like this: /automobile/automobile-page I want to be able to send ...
0
votes
0answers
12 views

Custom query variable not accessible

I have been trying to add a custom variable which I can access almost everywhere for various reasons. Here is how I add the query var: function add_query_var($vars) { $vars[] = "lang"; return $...
0
votes
0answers
12 views

Theme customisation - how to store common variables externally

I have been developing a custom extension for my theme over the last few weeks. This is my first time "developing" with Wordpress. All works fine and I am happy with the resulting functionality, ...
0
votes
1answer
33 views

Theme customisation - how to store javascript externally when it utilises php variables?

EDIT: Complete re-write I have been developing a custom extension for my theme over the last few weeks. This is my first time "developing" with Wordpress. All works fine and I am happy with the ...
2
votes
1answer
13 views

Taxonomy page template changing when using query variables

I'm hoping someone can help me fill in the gaps in my understanding of page templates and query vars: I've registered a custom taxonomy 'stream', and have set up a page template for that taxonomy, ...
2
votes
1answer
229 views

WordPress query through Products variation stock [closed]

I have WooCommerce variable products and a filter which is filtering products based on variation attributes. I have variation attribute depth which has numeric value (from 1 to 20) and the filter is ...
0
votes
1answer
145 views

Integer based rewrite isn't recognized for value of 1

I have a simple rewrite to pass a variable: // Add custom URL parameters function add_custom_query_var( $vars ){ $vars[] = "item_id"; return $vars; } add_filter( 'query_vars', '...
1
vote
1answer
56 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
337 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
30 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
23 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
19 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
35 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
61 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
44 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
33 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
38 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
31 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
356 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
354 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
181 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
2k 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
32 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
2k 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
34 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
411 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
139 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
344 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
203 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/ ...
4
votes
1answer
571 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
101 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
198 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', '...
3
votes
3answers
2k 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
680 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
359 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
3k 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
31 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
53 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 ...
2
votes
1answer
332 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
460 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
1k 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
111 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
76 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
382 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
2k 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
143 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=...