WordPress.org

Ready to get started?Download WordPress

Forums

Get posts that belong to certain taxonomy term? (2 posts)

  1. balladanna
    Member
    Posted 1 year ago #

    Hi,

    I'm trying to find a way to display a list (or thumbs) of posts that belong to particular Taxonomy.

    To make it clearer, I have a taxonomy 'Digest' and I've ID's: 'issue-1', 'issue-2', 'issue-3', etc... registered under that taxonomy.

    I wish to display posts that belong to 'issue-1' for example on my Issue-1 page.
    I can make separate templates for each issue, just to point at different 'issue-x' from my 'Digest' taxonomy, that's fine. I just can't get inside to see list of my posts.

    I tried to add this to my ISSUES.php for example, but it doesn't work:

    $args = array(
    'post_type' => 'post',
    'tax_query' => array(
    array(
    'taxonomy' => 'Digest',
    'field' => 'slug',
    'terms' => 'issue-1-12'
    )
    )
    );

    I appreciate any help or suggestion.

  2. vtxyzzy
    Member
    Posted 1 year ago #

    If you are trying to list all posts in that taxonomy, this should work:

    $args = array(
       'post_type' => 'post',
       'tax_query' => array(
          array(
             'taxonomy' => 'Digest',
             'field' => 'slug',
             'terms' => array('will-not-match-any'),
             'operator' => 'NOT IN'
          )
       )
    );

    There may be a simpler way, but since the 'tax' parameter has been deprecated, I do not know it.

Topic Closed

This topic has been closed to new replies.

About this Topic