CustomPress Search Results Mixed from Post and Custom Posts

Using CustomPress for Posts and set up custom posts as Staff. However, when I search using the backend search option, the results show them linked somehow.

For instance, when I add “Cribb” in the All Staff search option, it includes results from Posts and not just Staff.

Same thing happens when am in Posts and search for the same word, it shows posts and also Staff.

  • Dimitris
    • Support Star

    Hello there David,

    hope you’re doing well today! :slight_smile:

    I tried to replicate this in a testing site of mine, but I couldn’t, as search results weren’t getting mixed between my custom post type and native Posts.

    As your website seems to timeout now (it throws a 522-timeout error from Cloudflare), I couldn’t check your exact settings though. Please let me know here in your next reply when the website is accessible again so I can give this another look.

    If you need assistance for the 522 error, please do come to find us in our live chat service.

    Warm regards,

    Dimitris

  • David
    • The Crimson Coder

    Dimitris –

    Thanks for the response. I found the error late last night.

    add_filter( ‘pre_get_posts’, ‘berkeley_cpt_search’ );

    function berkeley_cpt_search( $query ) {

    if ( $query->is_search ) {

    $query->set( ‘post_type’, array( ‘post’, ‘movies’, ‘products’, ‘staff’, ‘elected’, ‘portfolio’ ) );

    }

    return $query;

    }

    That is what I had, but it has a flow. I had to put this in.

    if ( $query->is_search && !is_admin() ) {

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.