0

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:

  1. Updated the category description of the category which is not pulling in category page.
  2. 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 } ?>

 

1 Answer 1

1

You can use pre-defined function to get a category description.

category_description();

Visit for more information to Retrieve category description.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.