• 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

Viewing 6 replies - 1 through 6 (of 6 total)
  • 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(', ') ?>

    Thread Starter 840333

    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

    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

    Thread Starter 840333

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

    shalako

    (@shalako)

    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!)

    shalako

    (@shalako)

    follow up. i solved it this way:

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Category description in single post..’ is closed to new replies.