Title: PHP Struggles
Last modified: August 18, 2016

---

# PHP Struggles

 *  [Hannah S.L.](https://wordpress.org/support/users/fernashes/)
 * (@fernashes)
 * Automattic Happiness Engineer
 * [21 years, 3 months ago](https://wordpress.org/support/topic/php-struggles/)
 * Hey all… question. I need to get a hold of the name of the category of each post
   but I can’t figure out how.
 * $cat=the_category();
    The line above always causes the category name to be printed…
   $cat is NOT filled.
 * Proof of that is this line:
    echo $cat.’blkaat’;
 * $cat isn’t printed, but that nonesense is.
 * Can somebody give me a hand with what exactly “the_category()” function is doing?

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Thread Starter [Hannah S.L.](https://wordpress.org/support/users/fernashes/)
 * (@fernashes)
 * Automattic Happiness Engineer
 * [21 years, 3 months ago](https://wordpress.org/support/topic/php-struggles/#post-152930)
 * [http://ragwings.org/wordpressplugins/cat-icon.phps](http://ragwings.org/wordpressplugins/cat-icon.phps)
 * This is an older version (for WP 1.2) that I just used to check and see how THEY
   managed to get a hold of the category. They used the following:
 * $cat=get_the_category();
 * However, when I try it, $cat is set to “array”. For every single post, doesn’t
   matter what the category actually is.
 * Please tell me somebody can help me out…
 *  Thread Starter [Hannah S.L.](https://wordpress.org/support/users/fernashes/)
 * (@fernashes)
 * Automattic Happiness Engineer
 * [21 years, 3 months ago](https://wordpress.org/support/topic/php-struggles/#post-153096)
 * Still nobody who can give me a hand?
 *  [DianeV](https://wordpress.org/support/users/dianev/)
 * (@dianev)
 * [21 years, 3 months ago](https://wordpress.org/support/topic/php-struggles/#post-153102)
 * This is the WordPress 1.2.2 code for showing the category name on post pages:
 * `<?php the_category() ?>`
 * Essentially, it substitutes the name of the category. If yours isn’t doing that,
   I’m not sure why.
 *  Thread Starter [Hannah S.L.](https://wordpress.org/support/users/fernashes/)
 * (@fernashes)
 * Automattic Happiness Engineer
 * [21 years, 3 months ago](https://wordpress.org/support/topic/php-struggles/#post-153194)
 * I realize that it works for WP 1.2 … but it won’t work in 1.5 and that’s what
   I need a solution for. Thanks for the suggestion, though.
 *  [TechGnome](https://wordpress.org/support/users/techgnome/)
 * (@techgnome)
 * [21 years, 3 months ago](https://wordpress.org/support/topic/php-struggles/#post-153196)
 * have you checked the codex to see what tags are available?
 * Tg
 *  [TechGnome](https://wordpress.org/support/users/techgnome/)
 * (@techgnome)
 * [21 years, 3 months ago](https://wordpress.org/support/topic/php-struggles/#post-153197)
 * A quick check (<15 seconds) and I find this:
    [http://codex.wordpress.org/Template_Tags/the_category](http://codex.wordpress.org/Template_Tags/the_category)
 * If you want the name of the cat, try [http://codex.wordpress.org/Template_Tags/single_cat_title](http://codex.wordpress.org/Template_Tags/single_cat_title)
 * Tg
 *  Thread Starter [Hannah S.L.](https://wordpress.org/support/users/fernashes/)
 * (@fernashes)
 * Automattic Happiness Engineer
 * [21 years, 3 months ago](https://wordpress.org/support/topic/php-struggles/#post-153198)
 * Tg,
 * Yes, I’ve read most of the codex by now… but I think you found it!
    *crosses 
   fingers and goes off to try and play nice with PHP*

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘PHP Struggles’ is closed to new replies.

 * 7 replies
 * 3 participants
 * Last reply from: [Hannah S.L.](https://wordpress.org/support/users/fernashes/)
 * Last activity: [21 years, 3 months ago](https://wordpress.org/support/topic/php-struggles/#post-153198)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
