0

I am using ACF to create a custom post type (CPT = "books"). I cannot get the CPT to appear in Wordpress search results (I tried both default Elementor search widget and Jetsearch)

I have tried the following:

  add_filter( 'pre_get_posts', 'custom_post_type_search' );
   function custom_post_type_search( $query ) {
      if ($query->is_search) {
         $query->set('post_type', array( 'post', 'books'));
      }
   return $query;
   }

Nothing seems to work. The CPT is visible, queryable, and is NOT excluded from search.

Any ideas?

Thanks in advance :)

0

Browse other questions tagged or ask your own question.