• Anonymous User 8219565

    (@anonymized-8219565)


    Hi, I’d like to know please how to exclude certain PAGES from search results.
    I used this script on other WP sites, but I don’t figure out where to use it with Mantra!!

    <?php
    function filter_where($where = ”) {
    if ( is_search() ) {
    $exclude = array(534,539);

    for($x=0;$x<count($exclude);$x++){
    $where .= ” AND ID != “.$exclude[$x];
    }
    }
    return $where;
    }
    add_filter(‘posts_where’, ‘filter_where’);
    ?>

    Mantra is great!
    Thanks!

Viewing 1 replies (of 1 total)
  • This should work by just placing it in the (child) theme’s functions.php file…

    Or you could use a plugin like WP Hide Posts which, despite its name, can also hide pages from appearing in various places.

Viewing 1 replies (of 1 total)
  • The topic ‘Exclude PAGES from search’ is closed to new replies.