Anonymous
Unregistered
Posted 4 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
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(', ') ?>
Anonymous
Unregistered
Posted 4 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
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
Anonymous
Unregistered
Posted 4 years ago #
I did.. However that default only seems to work when displaying a category, not when displaying a post FROM a category :(
shalako
Member
Posted 4 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!)
shalako
Member
Posted 4 years ago #
follow up. i solved it this way:
<?php $category = get_the_category(); echo $category[0]->category_description; ?>