How to add $args to any running wp_query from function.php?

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.

Topic wp-query Wordpress

Category Web


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).

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.