The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] Display category description on single posts within that category (6 posts)

  1. joelwalsh
    Posted 11 years ago #

    How do I call the category description (of the current post's category) on a post's single page?

    My reason for wanting this is that I have a disclaimer in the category description (for instance, posts about medical subjects should not be taken as medical advice etc.).

  2. joelwalsh
    Posted 11 years ago #

    Is the category description not part of the "loop" I hear so much about? Does it have to be called "outside the loop" unlike other tags?

  3. skippy
    Posted 11 years ago #

    You should be able to use category_description() to display the category description. You may specify a category ID. If not specified, the current category will be used.

  4. joelwalsh
    Posted 11 years ago #

    <?php echo category_description(); ?>

    Works when I supply a category ID number but when it's left blank it doesn't produce anything.

    You can see it here: http://upmarketnewsletters.com/articles/test-opinion/

  5. joelwalsh
    Posted 11 years ago #

    I figured it out:

    foreach((get_the_category()) as $cat) {
    echo $cat->category_description . ' ';
    } ?>

  6. navigadget
    Posted 10 years ago #

    The above doesn't really work. It displays the main category description at all times.

    So there isn't a way to show the category description without having to hard-code the category number yet.

Topic Closed

This topic has been closed to new replies.

About this Topic