Wrong results for search query

[ad_1]

Sorry this was my fault i had code in my functions.php causing this

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

I fixed the issue using a better code below

function exclude_all_pages_search($query) {
    if ( $query->is_main_query() && $query->is_search() && ! is_admin() ) {
        $query->set('post_type', array( 'post', 'advert' ) );
    }
}
add_action('pre_get_posts','exclude_all_pages_search');

Hi,
ok thanks for the feedback, i am marking this thread as resolved then.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer