postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id '; } return $join; } /* ************************************************************** * add filter where to post_meta ************************************************************** */ add_filter( 'posts_where', 'perfetto_search_where' ); function perfetto_search_where( $where ){ global $pagenow, $wpdb; // Filter only when performing a search on edit page on all page / post / custom post type if ( is_admin() && $pagenow=='edit.php' && $_GET['s'] != '') { $where = preg_replace( "/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/", "(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->postmeta.".meta_value LIKE $1)", $where ); } return $where; } /* ========================================================================= * end of program, php close tag intentionally omitted * ========================================================================= */