Need help? Check out our Support site, then


Show/Hide Category Descriptions

  1. Hi,

    I'm designing a new theme for a friend's blog, and I have it set up so that category descriptions are displayed at the top of each category page. I'm using this code:

    <p><?php echo category_description(); ?></p>

    And the style sheet formats the paragraph so it has a gray background and a border. It works great.

    Here's the problem: Not every category has a description, and when there's not a description, the page displays an empty, ugly gray box.

    Can someone help me with an IF statement that would check to see if there's a category description, and if there is, display it in the gray box; if there's not, don't display anything?

    I'm thinking it has something to do with checking to see if the strlen variable is 0, but I'm not familiar enough with PHP to get the syntax right.

    Any help would be much appreciated!!

  2. As we have no access to .php files here, I'll assume your friend's blog is self-hosted and not hosted by wordpress.com. If so, you need to be at http://wordpress.org/support

    A sticky at the head of the forum explains the differences between .com and .org.

    Love the avatar!

  3. Thanks, ellaella!! Sorry about that- I forgot there were two different forums. And thanks for the compliment on my girl-- her name is Rhona. :)

  4. Give her an apple from my avatar. :)

    Happy blogging.

  5. Thanks a lot for your help mate. i really need this code. Cheers.

Topic Closed

This topic has been closed to new replies.

About this Topic