[wp-hackers] Include custom post type to search results

Dmitry Tokmakov dmitry at getmoxied.net
Sun Jan 27 22:57:22 UTC 2013

Hi all,

I'm experiencing the issue:
I created custom post type "recipes", then I transferred some regular posts to new custom post type (just switched post type by looping through posts using wp_update_post()  ):

$recipes = get_posts('post_type=post&cat=3&posts_per_page=-1');
  foreach ($recipes as $recipe) {
        $post_array = array(
          'ID' => $recipe->ID,
          'post_type' => 'recipes'
        wp_update_post( $post_array );

Then I added code below to functions.php to include custom post type in the search results, but it didn't make any difference - still no custom posts in the search results.
function SearchFilter($query) {
  if ($query->is_search) {
  return $query;

Any ideas ?

Thank you in advance! 


More information about the wp-hackers mailing list