Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #6 from jmr06005/master
Fixing search
  • Loading branch information
jmr06005 committed Jul 19, 2017
2 parents 87981a3 + 7697822 commit ac6eaf4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion grandchild-functions.php
Expand Up @@ -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;
};
Expand Down

0 comments on commit ac6eaf4

Please sign in to comment.