Search all posts + custom post type posts without search term
-
$query->set('post_type', array("cpt", "post"));
add_filter('pre_get_posts', 'search_filter');Hi, I set the post types with
pre_get_postsfilter as mentioned above.Now there are three circumstances:
1) I search without terms:
?s=this will get only the wp core posts, ‘cpt’ custom post type is not showing.2) I search with terms:
?s=search+termthis will get me both ‘cpt’ and wp core posts.3) I search with:
post_type=cptthis will get all the ‘cpt’ posts.Is there any way to find both ‘cpt’ and wp core posts in the point 1 like in the point 2?
Thanks!
The topic ‘Search all posts + custom post type posts without search term’ is closed to new replies.