Support » Fixing WordPress » Capture Category ID on Category Archive Page?

  • Hi,

    Can’t find info on this anywhere in Codex or forum. On a category archive page for a parent category, I want to display in a line of links the child categories for that parent category.

    I even tried brute force, grabbing the cat= value from the query string (e.g. $catID = $_GET[‘cat’];) but that doesn’t appear to work when running mod_rewrite.

    If I’m not mistaken, I can run wp_list_categories but I need the category parent id. That’s the piece that I need to know how to get it within the WP system.

    Thanks for any ideas!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try using <?php $this_category = get_category($cat);?>. you can then reference the category id using $this_category->cat_ID.

    Thanks, esmi, but it didn’t work. Here’s what I’ve got for a parent category archive page:

    $this_category = get_category($cat);

    I want this sort of output:

    Child Category 1 | Child Category 2 | Child Category 3

    Any help would be much appreciated. I’m bummed it is so hard to do something that to me, at least, seems rather basic and common.


    echo get_query_var('cat');

    Will output the ID of the current category..

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Capture Category ID on Category Archive Page?’ is closed to new replies.