diff --git a/grandchild-functions.php b/grandchild-functions.php index d9f8e62..dbe7941 100644 --- a/grandchild-functions.php +++ b/grandchild-functions.php @@ -70,7 +70,16 @@ function gradschool_breadcrumbs(){ function filter_search($query) { if ($query->is_search) { - $query->set('post_type', array('post', 'courses')); + // Get post types + $post_types = get_post_types(array('public' => true, 'exclude_from_search' => false), 'objects'); + $searchable_types = array(); + // Add available post types + if( $post_types ) { + foreach( $post_types as $type) { + $searchable_types[] = $type->name; + } + } + $query->set( 'post_type', $searchable_types ); }; return $query; };