• Hi there,

    I understand that I can filter the search results by hooking into ‘pre_get_posts’, but has anyone a tip how to exclude custom posts from a certain user group (namely, ‘Subscribers’)? I get so far as to exclude a particular type of custom posts (namely ‘xxx’, but miss the bit of excluding these custom posts written by a certain user group:

    // search filter
    function search_filter($query) {
    if ( !$query->is_admin && $query->is_search) {
    $query->set(‘post_type’, array(‘xxx’,’post’) );
    }
    return $query;
    }
    add_filter( ‘pre_get_posts’, ‘search_filter’ );

    Thanks so much for any help!

  • The topic ‘Hide custom posts from certain user group in search results?’ is closed to new replies.