Show/Hide Category Descriptions

  • Author
    Posts
  • #228933

    stablegirl
    Member

    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!!

    #229125

    ellaella
    Member

    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!

    #229130

    stablegirl
    Member

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

    #229131

    ellaella
    Member

    Give her an apple from my avatar. :)

    Happy blogging.

    #229411

    geetkunal
    Member

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

The topic ‘Show/Hide Category Descriptions’ is closed to new replies.