I using this php filter for search box in my wp website.
I know this is wrong because the filter show me only the last query, how I can write the code in the way both query work?

function SearchFilter($query) {
    if ($query->is_search) {
           $query->set('post_type', 'post');
           $query->set('post_type', 'course');
       }
    return $query;
}
add_filter('pre_get_posts','SearchFilter'); 

Thank you.

Read more here: php query, work only one at time


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: