Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Make Custom Post Type searchable
<?php
add_filter( 'the_search_query', 'add_custom_post_type_to_search' );
/**
* Make Custom Post Type searchable
*
*/
function add_custom_post_type_to_search( $query ) {
if ( $query->is_search ) { $query->set( 'post_type', array( 'site', 'plugin', 'theme', 'person' )); }
return $query;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment