Support » Themes and Templates » adding description to category as introduction

  • Resolved qfwm2001

    (@qfwm2001)


    I have been looking around for how to get descriptions for a category to be displayed. I know this has been answered in multiple forums but the information is cryptic for someone with no code experience. I keep seeing this code
    <p><?php echo category_description(); ?></p>
    thrown around as a way to make the description show on website. My question is where does it go exactly? I have seen several places suggested that this can be placed to get the desired result, but cannot seem to find those locations in my archive.php. I can’t find category.php.
    I think what I am looking for is a really broken down explanation of how to accomplish this. Or if you have any other way to get some static text to appear at the top of a category page.
    I am a wordpress simpleton, and appreciate any help.
    I am using custom community theme
    wordpress version 3.3.1

    I am using custom community theme
    wordpress version 3.3.1
    http://www.thepasoapbox.com

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

    (@esmi)

    Forum Moderator

    where does it go exactly?

    Usually in the theme’s category.php file. If you don’t have such a file, then you’d need to add it to archive.php.

    That is what i have seen when searching. I am confused about where to put it in the archive.php. I am very green at this and have the understanding that this is a simple thing to do. Just not sure how.
    Many forums say put it under single_cat_title();?, but when I look at the archive.php in wordpress editor; I just don’t see that line.
    esmi, I appreciate your time on this. I think I saw you post about this very thing before. Can you tell me where in archive.php I should palce this code?
    Thanks again for quick response.

    where would you like the catagory description to show?

    to have the description below ‘You are browsing the Blog for …’

    add this code

    <?php if( is_category() ) echo '<p>'.category_description().'</p>'; ?>

    in archive.php just above the line (line 24) with:

    <div class="navigation">

    alchymth, thank you so much. that is exactly what i was looking for. thanks also to esmi, you both rock it.

    I’m sorry to add a question in this post but it’s almost the same I need,

    How can I get the category id instead of the -description-?

    I want to add some functionality when my visitors comes to a specific category.

    I know the ID I’m looking for (using the $id = get_cat_id('Búsqueda'); I got a 47). Well, now I need to know that I’m browsing the 47 category to display not the posts, but the functionality that I want to add in my site.

    Thanks

    get_query_var('cat') will return the category ID in a category archive page.

    a useful conditional would be:

    is_category() http://codex.wordpress.org/Function_Reference/is_category

    Great alchymyth,

    works great,

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘adding description to category as introduction’ is closed to new replies.