I have created the category page using category.php
template where I have pull the category description. I can see the code is working fine as some of the category description are pulling in the front-end while some of the category description is not showing in category page. I could not find any solution for it.
Here is what I have tried:
- Updated the category description of the category which is not pulling in category page.
- I also tried to verify slug conflict by renaming the slug but still its not working.
Below is the code in my category.php file to pull the category description:
<?php if(is_tag()){ ?>
<p><?php
$categories = get_the_tags();
echo $categories[0]->description;
?></p>
<?php } else { ?>
<p><?php
$categories = get_the_category();
echo $categories[0]->description;
?></p>
<?php } ?>
I have created the category page using category.php
template where I have pull the category description. I can see the code is working fine as some of the category description are pulling in the front-end while some of the category description is not showing in category page. I could not find any solution for it.
Here is what I have tried:
- Updated the category description of the category which is not pulling in category page.
- I also tried to verify slug conflict by renaming the slug but still its not working.
Below is the code in my category.php file to pull the category description:
<?php if(is_tag()){ ?>
<p><?php
$categories = get_the_tags();
echo $categories[0]->description;
?></p>
<?php } else { ?>
<p><?php
$categories = get_the_category();
echo $categories[0]->description;
?></p>
<?php } ?>
Share
Improve this question
edited Jul 28, 2020 at 12:50
fuxia♦
107k38 gold badges255 silver badges459 bronze badges
asked Jul 28, 2020 at 12:05
Sushil ShresthaSushil Shrestha
31 bronze badge
1 Answer
Reset to default 1You can use pre-defined function to get a category description.
category_description();
Visit for more information to Retrieve category description.