0

Thanks in advance for any help. I've created a page that lists the taxonomy of a custom-post-type. The issue I'm running into is the page that links from this listing should only pull the category and a placement code (in the example that's standard). It's pulling the placement but how do I get it to add in the dynamically created category pulled from the previous page.

Code that dynamically pulls taxonomy (category header). This pulls the right category on the page.

$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); echo $term->name;

Code below that pulls on the particular placement. How do I add the dynamically pulled taxonomy pulled by code above so content meets both criteria.

$args = array(
'post_type' => 'buyersguide', 
'meta_query' => array(
    array(
        'key' => 'Placement',
        'value' => 'standard',
        'compare' => 'LIKE'
    )
)
);
query_posts($args);

1 Answers1

0

You can fix this by using the following code:

$args = array(
 'post_type' => 'buyersguide', 
 'meta_query' => array(
    array(
        'key'     => 'Placement',
        'value'   => 'standard',
        'compare' => 'LIKE'
    )
 ),
 'tax_query' => array(
    array(
        'taxonomy' => $term->taxonomy,
        'field'    => 'slug',
        'terms'    => $term->slug
    )
 )
);

query_posts($args);

For more information on taxonomy parameters, go to: Taxonomy Parameters - WP_Query

Mohamed E.
  • 333
  • 4
  • 8