[resolved] How to display the term_ID in archive page (2 posts)

  1. Zen Gonzaga
    Posted 4 years ago #

    <?php $current_category = single_cat_title("", false); ?>
    <span class="category-title"><?php echo $current_category; ?></span>

    This is what i'm using to display the Category Name in archive, but i need some code to display it's term_ID. I'm Using Custom Post Type and this a custom taxonomy. I seriously don't know what it's called.. but I know it's a Custom Post Type Category.

    I tried the getCurrentCatID() function not working.
    Also tried this $cat = get_category( get_query_var( 'cat' ) );. But also not working.

    global $wp_query;
    $category = $wp_query->get_queried_object();

    Tried everything. But NOTHING worked.

    *Hope you guys can help me with this. Stuck here forever.
    By the way, i'm trying to get the ID so i can get the child categories and display them in DROPDOWN BOX. Thanks

  2. Zen Gonzaga
    Posted 4 years ago #

    Here it is.. i hope it could help other newbie here :D

    <?php $current_category = single_cat_title("", false);
    echo $current_category;
    $id = get_queried_object_id($current_category);
    echo $id;

Topic Closed

This topic has been closed to new replies.

About this Topic