Forums › Forums › Search & Filter Pro › Search Field Showing Categories for CPT, Showing Categories as Empty (0)
Tagged: categories, cpt, custom post type, no search results
- This topic has 12 replies, 2 voices, and was last updated 4 years ago by Trevor.
-
Anonymous(Private) December 8, 2020 at 2:40 pm #269098
Hi,
I’m using SFP to filter a number of local shops by what they offer as far as online services. The custom post type is “ecommguide” and there are a number of categories. The category titles show properly in the search form but show as empty or no posts. FYI there are about 130 posts divided among the categories.
Here is the page:
http://brandonchamber.ca/shop-local/I’m using short codes on the same page using the WP rich text editor.
I add my custom post types to the functions file. Here is the cpt code in case I’ve missed a detail (I keep them pretty simple):
function include_custom_post_types( $query ) { global $wp_query;
if ( is_category() || is_tag() ) {
$post_types = get_post_types();
$custom_post_type = get_query_var( ‘post_type’ );
if ( empty( $custom_post_type ) ) $query->set( ‘post_type’ , $post_types );
}
return $query;
}
add_filter( ‘pre_get_posts’ , ‘include_custom_post_types’ );add_action( ‘init’, ‘create_post_type’ );
function create_post_type() {register_post_type( ‘ecommguide’,
array(
‘labels’ => array(
‘name’ => __( ‘Ecomm Guide’ ),
‘singular_name’ => __( ‘Ecomm Guide’ ),
‘taxonomies’ => array(‘category’),
),
‘public’ => true,
‘has_archive’ => true,
‘exclude_from_search’ => false,
‘supports’ => array( ‘title’, ‘editor’, ‘revisions’),
‘taxonomies’ => array(‘category’),
)
);}
Thanks!
ScottAnonymous(Private) December 8, 2020 at 3:10 pm #269121Hi!
OK – I’ve already gotten closer… by unchecking “Enable Auto Count” I now have the number of posts per category showing (e.g. Food & Beverage (14)) but now I am returning no results on the form. I have also simplified my form to remove extra chances of simply creating a form incorrectly.
Criteria I’m using:
Post type to search: Ecomm Guide
Results per page: 150
Auto submit form? checked (I’ve tried using just a submit button, but same result)
Field relationships: AND
Enable Auto Count: not enabled
Update the Search Form on user interaction: checked -
AuthorPosts