WordPress.org

Ready to get started?Download WordPress

Forums

Category description in single post.. (7 posts)

  1. Anonymous
    Unregistered
    Posted 5 years ago #

    Hello,

    I want to have the category description in my single post php..

    So every post will show the description of the category it was posted in.

    Now this works ok :
    <?php echo category_description(3); ?>

    However I want to have the description of the category of the active post someone is watching.. So how can I replace the '3' with the catid belonging to the active postid?

    Hope someone can help me out on this one!

    Thank you for your time and effort!
    Regards
    Edwin

  2. Roy
    Member
    Posted 5 years ago #

    I'm not sure this is what you mean, but I just have the category named (and linked) in the single.php, the same as in the index.php

    <?php _e('Category:') ?> <?php the_category(', ') ?>

  3. Anonymous
    Unregistered
    Posted 5 years ago #

    Not really.

    I need to know how to replace the '3' in this tag:

    <?php echo category_description(3); ?>

    with the category ID that belongs to the single post.

    Thanks
    Edwin

  4. moshu
    Member
    Posted 5 years ago #

    Did you read the documentation?

    category
    (integer) The numeric ID of the category for which the tag is to return the description. Defaults to the current category, if one is not set.

    Template_Tags/category_description

  5. Anonymous
    Unregistered
    Posted 5 years ago #

    I did.. However that default only seems to work when displaying a category, not when displaying a post FROM a category :(

  6. shalako
    Member
    Posted 5 years ago #

    was this resolved? i am also trying to figure out how to display category description on single.php (without hardcoding the category ID of course!)

  7. shalako
    Member
    Posted 5 years ago #

    follow up. i solved it this way:

    <?php $category = get_the_category(); echo $category[0]->category_description; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic