How to display posts of specific subcategory in WordPress (1 post)

  1. LoLina
    Posted 4 years ago #

    I created custom taxonomy called Products. It has three terms (categories): Furniture, Gift, Food. Each term has it's own children (subcategories). And I need to get a posts titles, who are in the specific subcategory.

    I have a code, which displays specific category (which term_id is 3) subcategories titles:

        $termID = 3
        $taxonomyName = "products";
        $termchildren = get_term_children( $termID, $taxonomyName );
        foreach ($termchildren as $child) {
            $term = get_term_by( 'id', $child, $taxonomyName );
            echo'<p class="menu_head"><a href="#">'.$term->name.'</a></p>
        <div class="menu_body">
             <a href="#">Link-1</a>
             <a href="#">Link-2</a>
             <a href="#">Link-3</a>

    And I need to get posts, who are in that subcategories, titles in <div class="menu_body"></div> instead of "Link-1", "Link-2", "Link-3".

Topic Closed

This topic has been closed to new replies.

About this Topic