Skip to content

Instantly share code, notes, and snippets.

@JiveDig
Created November 22, 2013 03:30
Show Gist options
  • Select an option

  • Save JiveDig/7594348 to your computer and use it in GitHub Desktop.

Select an option

Save JiveDig/7594348 to your computer and use it in GitHub Desktop.
// Include all custom post types in search
<?php
// Include custom post types in search
// @link http://thomasgriffinmedia.com/blog/2010/11/how-to-include-custom-post-types-in-wordpress-search-results/
add_action('pre_get_posts', 'include_post_types_in_search');
function include_post_types_in_search( $query ) {
if ( $query->is_search )
$query->set( 'post_type', array( 'post', 'download' ) );
return $query;
};
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment