How can I modify this code to make the search box include tags and meta
I would like the search in same box
if($_GET['s'] && !empty($_GET['s']))
{
$text = $_GET['s'];
}
if($_GET['type'] && !empty($_GET['type']))
{
$type = $_GET['type'];
}
$args = array(
'post_type' => $type,
'post_status' => 'publish',
's' => $text,
);
$query = new WP_Query($args);
post_type
then you don't need a newWP_Query
or a special$_GET['type']
, it'll automatically generate URLs withpost_type=xyz
in the URL that are picked up by WordPress. This also means that a lot of the existing answers will work for you (because you discard the main query and create a newWP_Query
those existing answers might not work for you, and you've made your search pages twice as slow).$_GET['type']
isn't set the$type
variable is undefined, yet you use it in the array even if it's undefined, which will give you PHP warnings and notices. I see no search box code in the Q