• zeromage

    (@zeromage)


    Hi, I am using the Grey Lagoon Theme and I am wondering how to display my category descriptions.

    My archive.php file looks like this (can someone tell me how to edit this code to display my category descriptions?):

    <?php get_header(); ?>

    <!–include sidebar–>
    <?php include(TEMPLATEPATH.”/sidebar.php”);?>

    <div id=”content”>
    <!–the loop–>

    <?php if (have_posts()) : ?>

    <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    <?php /* If this is a category archive */ if (is_category()) { ?>
    <h3><?php echo single_cat_title(); ?></h3>

    <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    <h3>Archive for <?php the_time(‘F jS, Y’); ?></h3>

    <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    <h3>Archive for <?php the_time(‘F, Y’); ?></h3>

    <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    <h3>Archive for <?php the_time(‘Y’); ?></h3>

    <?php /* If this is a search */ } elseif (is_search()) { ?>
    <h3>Search Results</h3>

    <?php /* If this is an author archive */ } elseif (is_author()) { ?>
    Author Archive

    <?php /* If this is a paged archive */ } elseif (isset($_GET[‘paged’]) && !empty($_GET[‘paged’])) { ?>
    Blog Archives

    <!–do not delete–>
    <?php } ?>

    <!– navigation–>

    <?php next_posts_link(‘« Previous Entries’) ?>
    <?php previous_posts_link(‘Next Entries »’) ?>

    <!–loop article begin–>

    <?php while (have_posts()) : the_post(); ?>
    <!–post title as a link–>
    <div class=”postspace3″>
    </div>
    <h2 id=”post-<?php the_ID(); ?>”>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></h2>
    <!–post time–>
    <b><?php the_time(‘l, F jS, Y’) ?></b>

    <!–optional excerpt or automatic excerpt of the post–>
    <?php the_excerpt(); ?>

    <!–one post end–>
    <?php endwhile; ?>

    <!– navigation–>
    <?php next_posts_link(‘« Previous Entries’) ?>
    <?php previous_posts_link(‘Next Entries »’) ?>
    <!– do not delete–>
    <?php else : ?>

    Not Found
    <?php include (TEMPLATEPATH . ‘/searchform.php’); ?>

    <!–do not delete–>
    <?php endif; ?>

    <!–archive.php end–>
    </div>

    <!–include footer–>
    <?php get_footer(); ?>

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Code like this should work, I think.

    if (is_category()) {
    $catID = intval( get_query_var('cat') );
    $cat = get_the_category($catID);
    echo $cat->description;
    }

    Thread Starter zeromage

    (@zeromage)

    Thanks, but where do I insert that code?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Wherever you want to display the description, I assume.

    Thread Starter zeromage

    (@zeromage)

    That would be in my archive.php file? Sorry, I’m a little slow, I’m really inexperienced with php/css.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Well, I don’t really know where you want to put the description so I can’t really answer that. It might be in your archive.php file, if you want the description to show up on archive pages.

    Try it a different way. Describe what you actually want to do. Don’t worry about how to do it yet, just say “I want the category description to show up here (link to your site) at this point in the page (describe place on page). Then somebody might be able to give you more specific instructions.

    Thread Starter zeromage

    (@zeromage)

    Okay, thanks. basically I want my category descriptions to show up on each category page, right before all the posts.

    Why the code to include category descriptions on archive pages isn’t part of the default theme I’ll never know… Each time I update WordPress I have to put this back in! :/

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

The topic ‘How do you display category descriptions?’ is closed to new replies.