how do i combine keyword search and taxonomy in a WP_query $args array Worpresss [closed]

I’m trying to figure out how to get the following code to work as one wp_query . i’m trying to filter the loop on the search values and the taxonomy values:

Both of these sections work independently but i’m looking to tie these into one query..?

I have tried various combinations but am getting no where….any ideas of the best approach to this issue…?

    global $query_string;

    $query_args = explode("&", $query_string);
    $search_query = array();

    foreach($query_args as $key => $string) {
        $query_split = explode("=", $string);
        $search_query[$query_split[0]] = $query_split[1];
    } // foreach
    $args = array(
    'post_type' => 'listings',
    's' => 's',
    'keyword' => $search_query['s'],
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'type',
            'field' => 'slug',
            'terms' => $search_query['type']
        ),
        array(
            'taxonomy' => 'rooms',
            'field' => 'slug',
            'terms' => $search_query['rooms']
        )
    )
);
    $the_query = new WP_Query($args);

0

Leave a Comment