'category description in single.php wordpress
any ideas.
this works fine in category.php <?php echo category_description(the_category_id()); ?>
but it does not work in single.php, just the category id shows up not the description.
any ideas, how to get this done?
thanks in advance
edited:
Solution 1:[1]
the_category_id()
has been deprecated. This should work instead.
$category = get_the_category();
echo category_description($category[0]->cat_ID);
Solution 2:[2]
Use
$category = get_category( get_query_var( 'cat' ) );
$category = $category->cat_ID;
To get current category ID, then echo the description
echo category_description($category);
This was used on Archive page (Category page) as at the time of running the code.
For a shorter version:
echo category_description(get_category(get_query_var('cat'))->cat_ID);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jackreichert |
| Solution 2 | Daniel Uko |
