• Resolved wassy83

    (@wassy83)


    Hi to all I really cannot figure out this after so many hour of searching.. I’m developing this website(still 60%) with the divi theme. I created 3 custom posts type

    struttura
    tour
    offerta

    but I cannot obtain search results from these 3 cpt.
    Following this link
    https://docs.pluginize.com/article/23-post-type-posts-in-search-results
    I added the below code

    /*cpt ui search*/
    function my_cptui_add_post_type_to_search( $query ) {
    if ( is_admin() ) {
    return;
    }

    if ( $query->is_search() ) {
    $cptui_post_types = cptui_get_post_type_slugs();
    $query->set(
    ‘post_type’,
    array_merge(
    array( ‘post’, ‘page’ , ‘tour’ , ‘struttura’, ‘offerta’ ‘project’ ), // May also want to add the “page” post type.
    $cptui_post_types
    )
    );
    }
    }
    add_filter( ‘pre_get_posts’, ‘my_cptui_add_post_type_to_search’ );

    but the only effect of this code is that the project cpt are displayed(these project cpt are a cpt integrated in the divi theme)but the cpt created with cptui are still not showed in the search results. I have already tried with other search forms and even with the wp base search with same results..
    in example I cannot search this cpt
    https://neos.anekitalia.com/tours/tour-sulle-ombre-di-alessandro-magno/

    many thanks

    • This topic was modified 6 years, 3 months ago by wassy83.

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

Viewing 5 replies - 16 through 20 (of 20 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    @danidub

    Between making sure that your post types are publicly queryable and available for in search, and trying the snippets found at https://docs.pluginize.com/article/23-post-type-posts-in-search-results I would need to be able to see what your constructed queries are ending up being, to really provide more possible insight.

    Unsure if you have other pre_get_post filtering that may be inadvertently affecting things, or some plugins that are focused around search, that may be playing their own parts.

    @tw2113 thank you for replying, I have found the error and it was nothing to do with the plugin CPT UI. Was another plugin Relevanssi blocking some results.
    Thank you! Issue solved.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome.

    I’m having the same issue. I found that the plugin that blocking the results from CPT is the polylang. Do you have any suggestions how to solve it?

    Edit: problem solved when assigned the custom post types to languages.

    • This reply was modified 5 years, 7 months ago by gtsoulou.
    • This reply was modified 5 years, 7 months ago by gtsoulou.
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Interesting but good to see you got it resolved. Thanks for the followup.

Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘cannot search custom post type’ is closed to new replies.