WordPress.org

Support

Support » How-To and Troubleshooting » How to include category name of single post in page title

How to include category name of single post in page title

Viewing 2 replies - 1 through 2 (of 2 total)
  • ba-bump!

    Couple ways:

    1. http://wordpress.org/support/topic/34542#post-195689

    2. More preferred way, place this at the top of your header (usually header.php) template:

    <?php $category = get_the_category(); ?>

    Then in your <title> element, something like the following (exact placement in the title is up to you):

    <?php if(is_single()) { echo echo $category[0]->cat_name; } ?>

    If #2 doesn’t work, let me know. There’s a way to duplicate what get_the_category() is doing for us here with the post’s data but even more globally.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to include category name of single post in page title’ is closed to new replies.