How to display the category ID for a category archive? (3 posts)

  1. uriash
    Posted 9 years ago #

    This is a question I've allready asked but then it followed another question which was resolved so I thought of opening a fresh new thread dedicated to this particular question which was'nt resolved :)):
    (I'll also try to extract the question to it's essence, so it'd be clearer)
    (now for the problem:)
    In the category archive page, I want to display it's category ID as the title. I used this code for that:
    <?php the_category_ID(); ?>
    but then if the most recent post is belonged to a child category then the ID would be the child's ID.
    then I tried this way:
    $cat = single_cat_title(); echo $cat->cat_ID;

    but this time it insisted to display the category name, although I wrote echo $cat->cat_ID.
    Can anyone help me with that?

  2. maestrosync
    Posted 9 years ago #

    Yes! This is something I really need to know as well.

  3. Kafkaesqui

    Posted 9 years ago #

    $cat is a global var in WordPress, the value of which is the category ID whenever a category query occurs.

Topic Closed

This topic has been closed to new replies.

About this Topic