i have created a Search template in elementor pro, i'm using Archive Posts widget to show the result. but the problem is i want to include the CPT in the result.
i tried the pre get post function, but its not working, it only shows the posts
function vikram_include_custom_post_types_in_search_results( $query ) {
if ( $query->is_main_query() && $query->is_search() && ! is_admin() ) {
$query->set( 'post_type', array( 'service', 'specialty' ) );
}
}
add_action( 'pre_get_posts', 'vikram_include_custom_post_types_in_search_results', 10, 1 );
plz guide me how to do this
thanks in advance