Skip to content

Instantly share code, notes, and snippets.

@chrdesigner
Created August 21, 2015 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrdesigner/df6499c33d8429ac1dba to your computer and use it in GitHub Desktop.
Save chrdesigner/df6499c33d8429ac1dba to your computer and use it in GitHub Desktop.
WordPress - Search in Specific Post Type
<?php
/*
* Search in Specific Post Type
*/
function search_specific_post_type($query) {
if ($query->is_search) {
$query->set('post_type', array('post'));
};
return $query;
};
add_filter('pre_get_posts', 'search_specific_post_type');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment