cannot search custom post type
-
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
offertabut 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
The page I need help with: [log in to see the link]
- The topic ‘cannot search custom post type’ is closed to new replies.