Questions tagged [query-variable]

The tag has no usage guidance.

39 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
0answers
144 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 ...
3
votes
0answers
106 views

query_vars Filter: Would You Ever Use It When $_GET is Available and You Don't Need a 'Pretty' URL?

I'm having a hard time wrapping my head around the uses cases/best practice for the 'query_vars' filter, and query_vars in general, when I could use the $_GET global instead. Given http://example....
2
votes
1answer
463 views

add_rewrite_rule query_var not being set

I have an unusual use of add_rewrite_rule (is there a usual use?) and I am getting some unexpected behavior. First here is my code: if(!empty($list_view_template)) add_rewrite_rule( "{$...
1
vote
1answer
36 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 = (...
1
vote
0answers
30 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 ...
1
vote
0answers
172 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 ...
1
vote
0answers
336 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 ...
1
vote
0answers
638 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
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
0answers
160 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 ...
1
vote
1answer
186 views

Is it safe to use $_POST directly in my plugin instead of using admin-ajax.php to receive data from ajax?

When we want post data from frontend to WORDPRESS everyone says i must use admin-ajax.php. But i can add query vars and receive posted data in my plugin file using a global variable, and then i can do ...
1
vote
0answers
165 views

Wordpress query vars are not added

I'm currently trying to figure out how to get my custom url rewrites working (WP Rewrite the last two parts of the URL), while doing this I came across the following problem: I have made a custom ...
0
votes
0answers
11 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
31 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 ...
0
votes
1answer
24 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
2answers
30 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
46 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
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
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
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 ...
0
votes
1answer
32 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( '...
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
127 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....
0
votes
0answers
89 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
183 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', '...
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
52 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 ...
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
0answers
75 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
2answers
353 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 ...
0
votes
0answers
197 views

Connect custom rewrite rules and query variables to wordpress navigation

Setup for getting content My setup for getting custom content in Network of sites where many sites use the same custom data on the side of worpress generated content. Custom classes to get custom ...
0
votes
2answers
591 views

How do I pass custom shortcode-extracted variables (taxonomy) into a query function for WordPress RoyalSlider?

Plugin in question: http://dimsemenov.com/plugins/royal-slider/wordpress/ Background: This is a great plugin, and it features a 'post' version where the slider pulls content from posts. However, the ...
0
votes
0answers
136 views

Query var SEO URL

I've created a personal custom variable in a plugin. Now I've URL of this form: http://example.com/page/?var=ID. I want to have this kind of URL: mysite.com/page/var/name where name is retrived from ...
0
votes
1answer
37 views

Rewrite URL to plugin file

I'm creating a plugin that handles courses from a 3rd party system, I've created a add_rewrite_rule() so the url /course/32567 rewrites to /wp-content/plugins/course-plugin/course-page.php?code=32567 ...
0
votes
0answers
450 views

passing javascript variable into php wordpress

I am trying to pass variable from JS to PHP. I have this JS code that runs in my footer.php: <script> function printResponse(response) { if ( response.errorCode == 0 ) { var ...
0
votes
0answers
1k views

Passing query variables to a custom page template

On my website I have a custom post type called 'theme'. I wanted the homepage to display an archive of themes. For this the only approach that I could think of was to create a page template with a ...
0
votes
1answer
890 views

Passing variables in the permalink structure on a custom post type

I have a structure like this for my custom post types: domain.com/member/member-name/book/book-name Basically, I have a custom post type of member, and the member-name is the post. What I want to do ...