pre_get_posts + post__in
-
I use pre_get_posts filter for “exact-match” – everything works perfectly.
I want to add one more filter search among id “in-fav” (This is a filter for searching among fovorites posts)
// url ?s=family&exact-match=1&in-fav=1 function search_exact_match($query) { if ($query->is_search && isset( $_GET['in-fav'] ) ) { $query->set( 'post__in', array(63798,17137,101565) ); // fav ID's } if ($query->is_search && isset( $_GET['exact-match'] ) ) { $exact_match = '"' . esc_attr( get_search_query( ) ). '"'; $query->query_vars['s'] = $exact_match; } else { return false; } } add_action('pre_get_posts', 'search_exact_match');
when the plugin relevanssi is enabled – code(filter) does not work
(search is looking for in all id’s site)when the plugin relevanssi is off – code(filter) filter work
(search is looking for in array(63798,17137,101565) id’s site)how to properly perform this filter with relevanssi?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘pre_get_posts + post__in’ is closed to new replies.