Support » Fixing WordPress » Assigning post category to $cat on single.php

  • Well, I installed 1.5 and it’s been fantastic. I have a question, though. I’d like to have single.php display different headers/sidebars depending on the category of the post displayed thereon. I’ve broken those bits out into different pages, which display the content depending on the value of $cat, which works nicely for category queries, of course, but not individual posts, since $cat isn’t set. But it should be relatively simple to get that info and assign it to $cat, shouldn’t it? I’ve got this code at the top of single.php right now:

    if (!isset($_GET[cat])) { $cat = the_category(); }

    Which plainly does not work. I’ve gone through the fora & the codex, but I don’t get it. Should I be using single_cat_title instead, or something altogether else?

    Thank you in advance, any potential saviours.

  • The topic ‘Assigning post category to $cat on single.php’ is closed to new replies.