• Just upgraded to 1.5 and everything has gone fine so far except for one little problem.

    I have been changing the width of a div depending on the id number of the current post. Under 1.2, I used this:

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

    to get the ID number, and then performed a simple If:

    if ($single) {
    if ($cat->category_id == 26) {

    to branch accordingly. With get_the_category deprecated, I’m stumped as to how to replicate this functionality. The codex listed a block of code that was supposed to work as a substitute, but it generates an error when I try to use it. Please help!

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • get_the_category() is deprecated?

    Thread Starter monkeywrench

    (@monkeywrench)

    whoops, sorry, my mistake. I’m looking at too many versions of things. the_category_id was deprecated, so I replaced it a while ago with

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

    Now I’ve gone stupid and forgotten what was depracted and what works and what doesn’t.

    Anyway, after the upgrade to 1.5, that line now generates this error:

    Invalid argument supplied for foreach()

    So that’s actually the problem that I need to fix.

    It would have to run in The Loop (much like the_category_ID() would have to). Is that where you have it? I ask because I run similar code in my templates with no problems.

    Thread Starter monkeywrench

    (@monkeywrench)

    Rats. That must be the problem. Looks like that means I’m gonna have to re-structure some things from the way the loop worked in 1.2.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Trouble with deprecated get_the_category’ is closed to new replies.