admin管理员组

文章数量:1201361

Is it possible to add WP_Query arguments from functions.php to any of wp_query running on current page? For example, I want to add $args['order'] to current running wp_query on any pages.

Is it possible to add WP_Query arguments from functions.php to any of wp_query running on current page? For example, I want to add $args['order'] to current running wp_query on any pages.

Share Improve this question asked May 22, 2022 at 12:09 Manish ShahManish Shah 32 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Use a pre_get_posts hook to modify the relevant query variables, with conditional tags to target specific pages/queries (and probably return from the callback early on is_admin() so you do not affect dashboard queries).

本文标签: wp queryHow to add args to any running wpquery from functionphp