Support » Fixing WordPress » How to get the daughter cat ID on a Cat page

  • Hi!

    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!

Viewing 1 replies (of 1 total)
  • This will list all Categories that have a Category parent ID of 5

    <?php
    $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;
    }
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘How to get the daughter cat ID on a Cat page’ is closed to new replies.