Support » Fixing WordPress » Category ID or the eternal new question never resolved ?

  • Hello,

    I need the Category_ID in a loop to make conditionnal conditions and the function Category_ID is deprecated. So I have search a lot for the good method. I have found a get_the_category whitch is not working for me…

    I’m on WP1.5.2, I just want to obtain the cat ID of the current post, it’s possible I’m a little dummy but… I don’t succed and Wiki, Codex and forum give opposite informations.

    Is there someone who know the truth about it (the contemporary truth) ? And how to make ?

Viewing 5 replies - 1 through 5 (of 5 total)
  • it’s not possible. lol …

    tried this a while back and wade thru every single category function, nothing.. there was once a “the_category_id” but it has deprecated.. for whatever reason. Only way to get it is thru hacking a bit..

    it’s strange, isn’t it?

    Posts can be in multiple categories so the old method no longer worked properly. Will some variation of the example “replacement” on http://codex.wordpress.org/Template_Tags/the_category_ID not work for you?

    It’s totally unbelievable. If you can’t have the current cat ID, how do you make conditions if ?????!

    I have only 6 root category (no child). I absolutely need which category is current in my “single template”. When I say absolutely, it’s absolutely, because when it is a category, you have something display, and another, another display.

    I can’t ask my author to use templates for each post ! And templates won’t solve the problem when there is are if for an unique category…

    I made this so easely with b2 that I couldn’t imagine I won’t be able with WP ! How will I do ??? It’s not a bug, it’s a structural vice.

    Sorry, I have made a error in my code and

    <?php
    foreach((get_the_category()) as $cat) {
    echo $cat->cat_ID . ‘ ‘;
    } ?>

    works for me ! 🙂
    Always be carefull before crying too much… :-X

    Euuuh, always me…

    I use

    <?php
    foreach((get_the_category()) as $cat)
    {$cat->cat_ID;}
    ?>

    and after in my simgle template, I use a very basic if condition :

    if ($cat != 1)
    {echo ‘test’;}
    else
    {echo ”;}

    And my condition doesn’t work… ?? Is there some technical specification about this way of catching cat ID to explain this ?
    I don’t see the smallest error in my nano-code.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Category ID or the eternal new question never resolved ?’ is closed to new replies.