How to get the daughter cat ID on a Cat page (2 posts)

  1. borbs
    Posted 7 years ago #


    On a category page, I want to show, as featured posts, the posts inside an specific subcategory.

    For example, on the MOVIES category, I want to show, on a loop, ONLY the 'OPENING THIS WEEK' category. I know how to use multiple loops and stuff, but I'd like to get the ID from this subcat, not assign manually.

    Thank you!

  2. MichaelH
    Posted 7 years ago #

    This will list all Categories that have a Category parent ID of 5

    $subcats = $wpdb->get_results("SELECT term_id FROM $wpdb->term_taxonomy WHERE parent = '5'");
    foreach ($subcats as $cat) {
    echo 'this cat is a child of 5: ' . $cat->term_id;

Topic Closed

This topic has been closed to new replies.

About this Topic