Forum

Thread tagged as: Question, Addons, Blog

Display only sub-category / child category for blog post -- hide parent category

Hi, last week Drew helped me hide the sub-category and only show the parent category in a blog post.

Can the inverse be achieved--hiding the parent category and only displaying the sub-category?

To only display the parent Drew provided this solution:

Drew McLellan said:

You could test for catParentID being 0:

<perch:categories id="categories" set="blog">
   <perch:if id="catParentID" value="0">
       ... display your category ...
   </perch:if>
</perch:categories>

Thank you!!

Olympia Kyriakides

Olympia Kyriakides 1 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes:

<perch:if id="catParentID" match="gt" value="0">

Clever, thanks Drew!!