Wednesday 8 February 2017

Combined the tax_query and Meta _query of wordpress

WP_Query is a class defined in wp-includes/query.php that deals with the intricacies of a post's (or page's) request to a WordPress blog.

TAX_Query is Creating a taxonomy generally automatically creates a special query variable.which we can use to retrieve posts based on.

Use both the meta_query and the tax_query


 


$args =  array(
            'post_type' => 'avada_portfolio',
            'meta_and_tax' => TRUE,
            'tax_query' => array(
                    array(
                        'taxonomy'  => 'portfolio_category',
                        'field'     => 'slug',
                        'terms' => array($terms[0]->slug),
                        'operator'  => 'IN'
                    )
            ),
            'meta_query' => array(
                    array(
                        'key' => 'martygeocoderaddress',
                        'value' => $imap[1],
                        'compare' => 'LIKE',
                    ),
            )
        );

    $map_query= new WP_Query( $args );

No comments:

Post a Comment