I try echo on any page (I mean page on my site) all post IDs what I have in my taxonomy.

I found this:

get a list of posts from Custom Taxonomy

But I could not handle with it.

I want to echo all currently published post IDs what the taxonomy contains.

Name taxonomy = 'agency' Post type = 'job_listing'

<input value="<?php echo $idsTaxonomy"?>

And I would see output example:

420, 16, 5

Somone could help me? Thank you for help.

  • What do you mean when you say "I could not handle with it" regarding the previous question? Commented Jul 11, 2018 at 1:50
  • You can try this. Link Best regards Commented Jul 11, 2018 at 2:33
  • What exactly are you trying to achieve? What is this input used for? What is its name? Do you want all posts for given term in that taxonomy or all posts that have any term in that taxonomy? Commented Jul 11, 2018 at 6:44

1 Answer 1


Just some code to get started. This will get you all the IDs for job_listings that are assigned to term 4 in your taxonomy.

    $posts = get_posts( array(
        'posts_per_page' => -1,
        'fields' => 'ids',
        'post_type' => 'job_listing',
        'tax_query' => array(
                'taxonomy' => 'agency',
                'field' => 'term_id',
                'terms' => 4
    ) );

    echo implode( ', ', $posts );

Your Answer

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

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