WordPress.org

Support

Support » Plugins and Hacks » Category ID within the loop

Category ID within the loop

  • Can anyone tell me how I can determine the Category ID of the current post within the loop? or – if multiple categories, the ID of the final ‘child’ category?

    (Sorry – this is a re-posted question as I think it got lost before. Also many thanks to Kafkaesqui for help with a previous category question.)

    Thanks for any advice… I am impressed with the level of help so many members give.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Nobody have any ideas or knowledge on this for 1.5.1 ? (Last time I try – honest!)

    did you try: get_the_category()

    gets an array of category objects, which you can loop over:
    $catlist = get_the_category();
    foreach ($catlist as $cat) echo $cat->cat_ID;

    I don’t know which is the ‘terminal’ category, if they are sorted at all…

    -d

    David – thanks and sorry for time delay – got side-tracked!

    The old the_category_id was perfect for what I needed but is now deprecated. I will do some testing on your suggestion and perhaps work it out from there.

    Thanks again

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Category ID within the loop’ is closed to new replies.
Skip to toolbar