Title: Displaying category description?
Last modified: August 18, 2016

---

# Displaying category description?

 *  [brettr](https://wordpress.org/support/users/brettr/)
 * (@brettr)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/displaying-category-description/)
 * I’m using this in my header.php file:
 * <h1><?php wp_title(”); ?></h1>
    <div class=”description”> <?php if (!is_category())
   bloginfo(‘description’); ?></div>
 * The main blog tagline displays on every page. I’d like the category description
   to display when I’m on a post in a certain category. What is the best way to 
   do this?
 * Thanks,
    Brett

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

 *  Thread Starter [brettr](https://wordpress.org/support/users/brettr/)
 * (@brettr)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/displaying-category-description/#post-474737)
 * This will display the category description for each post within that category
   while displaying the blog description outside of the category (notice I only 
   have two pages):
 * <?php
    if( ($page_id != 8) && ($page_id != 2)) { $category = get_the_category();
   echo $category[0]->category_description; } else {bloginfo(‘description’);} ?>
 * page_id = 2 is the About page. However, it doesn’t return an ID when I’m on the
   about page. So the default category description displays instead. Any suggestions
   as to why the About page is not returning a page_id?
 * Thanks,
    Brett
 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/displaying-category-description/#post-474739)
 * While Pages don’t have categories in a visible, practical way to group them (
   as in the case of posts) – for internal technical reasons [so we were told!] 
   they always belong to the “default” category of your blog. More exactly, to the
   whatever was the default category in the moment when the Page has been created.
 *  Thread Starter [brettr](https://wordpress.org/support/users/brettr/)
 * (@brettr)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/displaying-category-description/#post-474748)
 * Yes – I understand that pages belong to the default category but why doesn’t 
   the About page have a page_id?
 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/displaying-category-description/#post-474749)
 * Well, the About Page does have an id – you just said above, it’s = 8.
    What I
   don’t understand: why are expecting that the code you posted would return a Page’s
   ID? I am not a coder, but there is nothing in that code to display any kind of
   page ID…
 *  Thread Starter [brettr](https://wordpress.org/support/users/brettr/)
 * (@brettr)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/displaying-category-description/#post-474762)
 * You’re right. I added this:
 * global $wp_query;
    $page_id = $wp_query->post->ID;
 * But then modified the code to use this:
 * if( !is_page() )
    { $category = get_the_category(); echo $category[0]->category_description;}
   else {bloginfo(‘description’);}
 *  [drew3000](https://wordpress.org/support/users/drew3000/)
 * (@drew3000)
 * [19 years ago](https://wordpress.org/support/topic/displaying-category-description/#post-475293)
 * I’m looking for the same thing. Like the original question asker, I’m referring
   to posts, not pages:
 * I’d like the category description to display when I’m on a post in a certain 
   category. What is the best way to do this?

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

The topic ‘Displaying category description?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 3 participants
 * Last reply from: [drew3000](https://wordpress.org/support/users/drew3000/)
 * Last activity: [19 years ago](https://wordpress.org/support/topic/displaying-category-description/#post-475293)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
