admin管理员组

文章数量:1327665

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 } ?>

 

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 } ?>

 
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
Add a comment  | 

1 Answer 1

Reset to default 1

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

category_description();

Visit for more information to Retrieve category description.

本文标签: categoriesSome of the category description not showing up in category page