1

Is there a way to get posts by taxonomy with specifing the current term.

My post type is (listings), and my taxonomy is (region) I need to change adriatique term to the current term in my post

    $args = array(
  'post_type' => 'listings',
  'showposts' => -1,
      'tax_query'  => array(
        array(
          'taxonomy' => 'region',
          'field'    => 'slug',
          'terms'    => array('adriatique')
        ),
      ),
     'posts_per_page' => 5
);

1 Answer 1

0

Write your query as a function if you have not already (so you can use it elsewhere) and pass the slug as a parameter to your function.

ie. function get_listings_by_region($region)

You can get the slug of the current term by using something like the following:

$queried_object->slug

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.