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 } ?>
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You can use pre-defined function to get a category description.
category_description();
Visit for more information to Retrieve category description.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0