pre_get_posts WP_User_Query
-
I’m trying to run a custom search, which filters via an array set in ACF.
Essentially, I’m storing a list of users (contacts) in an array, and, if that is set, I want to search through those users, only.
I thought this would work:
function searchfilter($query) { $my_contacts = array(11, 19); // setting just to check it's working $search_type = get_query_var('search_type'); if ($query->is_main_query() && $search_type == 'contacts' ) { $query->set('include', $my_contacts); } return $query; } add_filter('pre_get_posts','searchfilter');
But it doesn’t limit the query at all.
Appreciate any help!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘pre_get_posts WP_User_Query’ is closed to new replies.