Forum

Thread tagged as: Addons, Blog

Displaying a blog post's category in list view

Hello,

I've had a look at the documentation and I haven't been able to find a solution that has worked. I'm trying to outpput the category of the post in list view and i've tried,

<perch:category id="category" set="blog" />
     <perch:category id="catTitle" />
</perch:category>

and

<perch:categories id="category" set="blog" />
     <perch:category id="catTitle" />
</perch:categories>

I've freshly installed perch and the blog app so everything is up to date! Any ideas would be great, thank you

Chima Nwosu

Chima Nwosu 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

That second instance should be fine - is that how it appears in your post.html template?

Simon Clay

Simon Clay 127 points

I notice that, out of the box, the post.html template uses the id 'categories', so if you've not changed it, I think you would use:

<perch:categories id="categories" set="blog" />
     <perch:category id="catTitle" />
</perch:categories>

thank you for the replies. turns out it wasn't the same way it was inside post.html. The below worked eventually:

<perch:categories id="categories" set="blog">
  <a href="archive.php?cat=<perch:category id="catSlug" type="slug" />" class="catUrl">
      <perch:category id="catTitle" type="text" />
  </a>
</perch:categories>