Support » Plugins » Category description outside of the loop?

  • Hi everyone. I’m wondering if there is a way to show the category title and description outside of the loop. What I would like to do is when a visitor goes to a category page (e.g. the page shows the category title and description as entered in the admin section and then a list of the posts in that category. I am creating a separate template for this. I’ve looked through the category template tags and most tags either had to be in the loop or you had to hard code the category id into the template. (I dont want to have to create a separate template for each category). I’ve searched through the forum and couldn’t find a similar request. Let me know if you can help. Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • the template tag (function) category_description(category) returns the description for ‘category’ (a number, the id of the category you are interested in.
    If no parameter is specified, then the description for the currently set category on the the page you are is returned.
    This function only returns the category description and does not display, to display it you will need to ‘echo’ it.
    In your case,
    <?php echo category_description(); ?>
    should work fine.
    as another example,
    <?php echo category_description('8'); ?>
    would display the description for category with id = 8.
    hope this helps.

    This is what I’m looking for, but
    ‘<?php echo category_description(); ?>’
    doesn’t seem to return anything unless a parameter is sent with it. The problem I have is that I don’t want to hard code a ‘category id’ into the template as the template will be used for a number of categories.
    Is it possible to get the ‘id’ from the URI or some other source so I can insert it into the ‘category_description()’ function?

    <?php echo category_description($_GET[‘cat’]); ?>

    Is it possible to do this in 1.5? I added this code but nothing happened.

    It works in WP1.5.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Category description outside of the loop?’ is closed to new replies.