Support » Fixing WordPress » Use wp_query() to get post by certain tax

  • Resolved yanj2004

    (@yanj2004)


    I set up one tag with tag name as “COVID”, slug is ‘covid’.
    I want to get all of the post with this tag.

    tax_query' => array(
        array(
            'taxonomy' => 'covid', 
             'field'    => 'slug',                 
             'terms'    => array('the-slug'),      
             )
     )

    But it didn’t work.
    Actually I’m not sure what the field and terms are and where I can find their parametres.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter yanj2004

    (@yanj2004)

    When I click one tag, the url is as
    wp-admin/term.php?taxonomy=post_tag&tag_ID=48&post_type=post&wp_http_referer=%2Fwp-admin%2Fedit-tags.php%3Ftaxonomy%3Dpost_tag

    Thread Starter yanj2004

    (@yanj2004)

    tax_query’ => array(
    array(
    ‘taxonomy’ => ‘post_tag’,
    ‘field’ => ‘tag_ID’,
    ‘terms’ => 48,
    )
    )

    This does work for me 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.