Can't seem to find this in the codex.
How do I get the category id for the category i'm in in the archives page. ie. if i'm in http://www.example.com/flowers/
how do i get the category id of the flowers category?
Can't seem to find this in the codex.
How do I get the category id for the category i'm in in the archives page. ie. if i'm in http://www.example.com/flowers/
how do i get the category id of the flowers category?
http://codex.wordpress.org/Template_Tags/get_the_category
This code will output the cat ID you are in :
<?php
$cat = get_the_category();
$cat = $cat[0];
echo $cat->cat_ID;
?>
S.
That code doesn't work if a post is listed in more than one category, as it seems to display only the first category ID of the post listed on the archive page... which is the weirdest thing ever.
Still no reply on this?
Yes this code is not what we're looking for. Is there no way to pull the category ID of the category being listed on the archive page? I mean the URL shows it, so it has to be somewhere.
thanks.
Ah, I see the solution is here:
http://wordpress.org/support/topic/223331?replies=3
way to link to it.
This topic has been closed to new replies.