• Resolved Jack Sarlo

    (@redhalls)


    Hi,

    Can I exclude specific pages in search results by placing this code in the fuctions.php file:

    function jp_search_filter( $query ) {
    if ( $query->is_search && $query->is_main_query() ) {
    $query->set( 'post__not_in', array( 1,2,3,4,5,6 ) );
    }
    }
    
    add_action( 'pre_get_posts', 'jp_search_filter' );

    Replacing 1,2,3,4 by post id e.g. 1294

    Because the search results page built with elementor’s ‘archive post’ widget return thank you pages and so forth.

    Thanks

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Remove pages from search results…’ is closed to new replies.