I am currently trying to set up a search in Wordpress, though am having issues because I am currently losing the search term in the query. I believe this is because I am running a new query instead of setting the WP query.
Current problem
Currently I am running the following command (an example where I wish to search taxonomies feature
and location
and the search term.
if ($s_feature != "" && $s_location != "")
{
$s_feat_array = array(
'taxonomy' => 'feature',
'terms' => array($s_feature),
'field' => 'slug',
'relation' => 'AND',
);
$s_loc_array = array(
'taxonomy' => 'location',
'terms' => array($s_location),
'field' => 'slug',
);
$housequery['tax_query'] = array(
'relation' => 'AND',
'orderby' => 'title',
'order' => 'ASC',
$s_feat_array,
$s_loc_array
);
query_posts($housequery);
}
Unfortunately, this is not searching the submitted search term nor any other queries.
My attempt
I therefore think that it should be 'set' to $query
rather than running a new command. I have seen that the following code DOES work:
$query->set('post_type',array('houses'));
However, I have tried to modify the query as follows and instead I get a fatal error (Call to member function on a non-object):
$query->set(array('taxonomy','location','terms',
array($s_location),'field',array('slug')));
I think it's to do with the array not being structured correctly though am really quite puzzled, so any help would be greatly appreciated.