some_body
needs to be run as an action on pre_get_posts
.
Here’s an example of the entire process of adding new query vars.
Pay extra attention to myplugin_pre_get_posts
:
function myplugin_pre_get_posts( $query ) {
...
$city = get_query_var( 'city' );
...
}
add_action( 'pre_get_posts', 'myplugin_pre_get_posts', 1 );
Related Posts:
- WP Query. Is there a maximum size?
- Create a post builder skin in a plugin
- How to create algorithm for ordering posts in WordPress?
- Remove posts that start with similar words (like a delete duplicate posts plugin)
- Does WordPress validate inputs to all functions? (such as get_user_meta and insert_user_meta)
- Custom random quote widget breaks when used in multiple sidebars
- Using a function to change favorites listing
- Display post lists in 2nd paragraph
- How to debug error message: Cannot modify header information
- Using a post-signup hook to get user details
- How to enable specific plugin only based around shop manager role?
- How to change constants in WordPress wp-config.php programmatically?
- Restrict media upload size by format
- How to use a class from another plugin
- Override Plugin Script Fucnction in WordPress
- How to display custom sidebar in wordpress 5.5.2
- Calling plugin function inside custom plugin for onclick event
- Show function to super admin
- creating html reusable blocks via shortcodes
- get current date + 90 days and checking every day
- Adding a new field to the address field type in gravity forms
- Replacing a plugin function with a custom renamed function doesn’t work
- How to create an input field, and base the output on spreadsheet data? [closed]
- Facebook Messager Plugin
- Nested shortcode functions accessing variable
- Calling an attribute from a plugin shortcode
- Fatal error: Call to undefined function cmsms_theme_page_layout_scheme()
- How to call WordPress function other files
- All sites themes functions.php have been changed
- Customize permalink wordpress category id
- Conditional attributes and logic per product category
- Disqus deleted comments are syncing with wordpress but active comments do not
- Admin style for just one plugin in dashboard
- How to remove custom post type and add category and post name
- WordPress and a secondary database?
- Grab WordPress Salt Data From URL
- Ajax : Call undefined function plugin_function() … can’t call any plugin function
- WordPress get_avatar function not correct working
- WordPress metaboxes – textfield suggestion automatically populated
- bbPress plugin: forum lists not showing in correct order? [closed]
- plugin code is pulling information from database in one instance and not in other. What is wrong?
- Which file of wordpress manage plugins functionalities?
- How to create an option page for this simple plugin
- Difference and examples of esc_attr__() and esc_attr_e()
- How to set Noindex to all wordpress pages in a catergory?
- WooCommerce search products between price range using WP_Query
- Redirect to another page using contact form 7? [closed]
- What is @Action in WordPress?
- Improving the perfomance of a plugin action
- Display Custom Field Value on Admin Page Column
- List the authors that have written posts in a category
- Load Javascript from Plugin in One Page Only?
- Is there a best practice remediation for PhpStorm’s warning that void function the_post_thumbnail is used?
- the_tags : can we insert a class
- How to over-ride a file in a plugin? [closed]
- Overwrite category head title
- Plugin is a widget, but I want to call it in the head, can I?
- How to get plugin name from plugin file location
- Check if variable is set in filter
- Cannot get wpdb data (Error in a simple fuction) [closed]
- How to prevent additional code in functions.php to be removed once there is an update?
- correct validate and sql query
- correct sql query
- SQL query, error
- Checking the count within a foreach loop
- execute function after one completed
- How to keep variable `$post` to using in another file
- WordPress checkbox and Illegal string offset
- Image change on hover
- Passing stored variables to add_filter
- Plugin Development – Functions or Hooks?
- Proper way to use plugin functions in functions.php
- Undefined index: action plugin problem
- Taxonomy Drill-Down / Plugin Help – hierarchical queries within plugin?
- PHP script from functions php is loaded via admin-ajax to div…and the result is 0, not the desired content
- How to customize a title by passing query string?
- How to reset the plugins without deactivate the plugin
- plugins_url() works everywhere but wp_reqister_script()
- JQuery prepend a function
- Basics of changing plugin output
- Adding class to last list item? Not WP generated
- Replacing global wp_query
- Why can’t I call a (member) function from within a foreach?
- Are there action hooks for comments?
- Help with WP Business Directory Manager Plugin?
- What is the best way to cache pages on WordPress
- I changed .live() to .on() but change is not reflected on the server
- wp_dequeue_script for a Plugin
- Need to replace Currency Shortforms
- wp_enqueue_scripts
- Return multiple values in a shortcode attribute
- Always get creating a new table with foreign key
- get specific value of a array | PHP
- How to get specific string/value from an array? php [closed]
- Shortcode Attributes to Return different $_POST
- How to make a dynamic css class whose name changes every visit to confuse scraper
- Plugin onclick button activate other plugin
- wc_get_template new template does not showing up
- WordPress Stock Update Programatically
- Loading a plugin’s js file from functions.php