I pretty sure this filter lets you add an array of variables. I’ve not tested this:
function add_custom_query_vars( $vars ){
$vars[] = "variable1";
$vars[] = "variable2";
$vars[] = "variable3";
//... etc
return $vars;
}
add_filter( 'query_vars', 'add_custom_query_vars' );
Or another way of doing it would be to do this:
function add_custom_query_vars( $vars ){
array_push($vars, "variable1", "variable2", "variable3");
return $vars;
}
add_filter( 'query_vars', 'add_custom_query_vars' );
Related Posts:
- how to create a shortcode from a variable in plugin
- WP_Query leaking absurd amounts of memory
- Symbolic Links on dev box with plugins and stylesheets
- How to call images from your plugins image folder?
- Fatal error: Class ‘ms\WP_Query’ not found on plugin initialization [closed]
- Register custom query args parameter for WP_Query()
- Getting wrong relationship value in $args in wp_Query?
- Check for featured image in WP_Query
- Why Does get_posts() Return an Empty Set?
- How to Rewrite WordPress URL for a Plugin
- get_posts / WP_Query Memory size of 134217728 bytes exhausted
- How to ensure “the_content” filter runs only for the main displayed content?
- add_filter and remove_filter added before and after wp_query
- How to get all images and their thumbnails from wp media library
- Having Problem On Getting WP Post Gallery Images URL
- Mapping multiple URLs to same page
- URLs of plugin resources?
- How to create a dynamic page based on form data with a plugin?
- Use of global variables within plugin [closed]
- Handling form request from plugin file
- How to restore WP 5.4 behaviour where a numeric string could added to each page URL and parsed as “page” in WP 5.5?
- Cannot search post by taxonomy
- WP_Query with tax_query, order by most ‘matches’
- How to print raw query from WP_Query class just like in CodeIgniter
- Finding posts containing matching array elements in a meta field usign WP_Query
- Create a custom display order in the main menu
- manage_posts_custom_column, showing serial number using increment in loop
- Error : “Cannot use object of type WP_Post as array in”
- Proper way to run wp_query from inside a plugin
- Can wp_list_comments output into variable?
- using new WP_Query in save_post function alters $post
- Slow WP_query due to nested wp_query. Need Suggestions
- ORDER BY wp_post custom column name in wp_query
- How to fix Uninitialized string offset: error on a checkbox in WP Settings API
- How to create database table, add data, update and delete using wpdb via plugins?
- Elementor custom Query with ACF fields to show matching woocommerce products custom fields
- WP_Query filters
- How to fetch only current hour posts?
- How to get Metabox custom field to show checked if value is updated using post meta query?
- WordPress pre_get_posts with combined results of two queries (OR)
- Search: how to extend the existing search to include a custom table
- how to get all the child category name in a specified category name?
- how to invoke wordpress API from other existing PHP system
- Redirect to another page using contact form 7? [closed]
- How to query children by post name/slug
- 400 Bad Request, in wordpress theme development, wp_ajax
- Prevent WordPress automatically processing certain URL queries
- Can I use %category% like Templates in my Plugin?
- Store custom meta box data as serialized array
- how to load the comment template from a plugin
- How remove trashed WooCommerce orders from wc_get_orders() result?
- How can I programmatically change a MySql variable (foreign_keys_check)?
- Auto-complete or auto-suggest from stored data in database
- How to list all images used on a specific page?
- Pagination not working with custom wp_query
- Get Posts by IDs (optionally)
- Adjust query on single
- WP_Query order posts by category
- The URL of images on my website changed after being set as featured image
- Is it possible to use the MySQL’s ORDER BY FIELD() clause as part of the pre_get_posts hook?
- How to save page URL as a favorite
- Getting incorrect filepath inside custom block front-end output using @wordpress/create-block tutorial
- Multiple dynamic Tax Query – pass taxonomy argument from array
- Check current URL is 404 in pre_option_stylesheet filter hook
- WP_Query not ordering correctly
- How to check category name available or not
- Home page is not loading, where in other pages are displaying on the site
- Creating a return url for getting data from external api
- User meta query using Wildcard
- Group By in a Metaquery
- WP Query date_query with several date range
- Return raw image proxy for wordpress plugin
- How to pass a more variable with page/subpage in Wordprees URL?
- Making Woocommerce optimized for more than 500k products
- Post Pagination does not working on WP-Query
- pull data from wordpress database
- How can I query 3 posts from diferente categories (one of each category)
- Query only title/field/featured media of posts [closed]
- Custom MySQL query to pull out Advanced Custom Fields?
- Any way to make Apache’s internal redirect work?
- How can I see a varibles value when my plugin runs?
- Issue on Getting Images URL of the Post Gallery
- post_results filter confused by pagination in sidebar and main section
- How can I display a specific number of post in a category via a url
- How to add chunk of php, html, and sql code to variable an append to $content
- Get custom wp_query search results to appear on search.php
- Mapping multiple URLs to same page
- loop and in admin header problem
- How do I query posts and have their related taxonomies returned in the results?
- How to Rewrite WordPress URL for a Plugin
- My class function is not seeing GET url paramaters
- redirect word-press page with page values
- Best Way to Inventory the Media Library of a 200+ Multisite Installation?
- WordPress custom link with my plugin
- $_GET vs get_query_var()
- What is the meta_query key name for the woo product average rating? [closed]
- get the queried_object of an url
- Personalized URL for non-logged in WordPress
- filter on get_posts efficiently
- esc_url, esc_url_raw or sanitize_url?