wordpress - get the category of a post in the footer.php file

Discussion in 'PHP' started by mma freeroll, Apr 6, 2009.

  1. #1
    In the footer.php file of my theme, I'm going to get the php variable of the current post's category - is this possible?

    Thank you.
     
    mma freeroll, Apr 6, 2009 IP
  2. rochow

    rochow Notable Member

    Messages:
    3,991
    Likes Received:
    245
    Best Answers:
    0
    Trophy Points:
    240
    #2
    Yes. Within the loop, run WP's category function and assign it to a variable. Then, in the footer, you can echo the variable or do whatever you want.

    Done it once before, from memory get_the_category() is the one you want.
     
    rochow, Apr 8, 2009 IP
  3. omglol

    omglol Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It's get_the_category(). It returns all the categories of the post in an array, so you have to loop through it.
     
    omglol, Apr 9, 2009 IP