Forum

Thread tagged as: Question, Docs, Blog

perch_blog_post_categories doesn't load template

I am very new to perch and not yet familiar with what is Perch and what is Perch runway.

I added the blog addon and I'm trying to display the categories of each blog post, but perch_blog_post_categories() is only loading the default template?

perch_blog_custom(array(
                    'template' => 'post_in_list.html',
                    'each' => function($item) {
                        $item['categories'] = perch_blog_post_categories($item['postID'], 'post_in_list_category.html', true);
                        return $item;
                    }
                    ));

Can anyone help me find out why this the template that is being loaded is always post_category_list and to the one I am passing?

If it is a Perch Runway thing I think it should be stated clearly in the documentation.

Thanks

Abigail Stock

Abigail Stock 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You don't need to use a callback for this. In your post_in_list template, add the perch:categories tag pair from your post.html template.

Something like:

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

Thanks for answering so fast but I think I did not make myself very clear with the description.
What I want to achieve is to have listed each of the categories of a given post, not just all categories. which Is what I think you are telling me to do...

Rachel Andrew

Rachel Andrew 394 points
Perch Support

The code Drew has given you is to list the categories for an individual post.

You can see the same code in your post.html Master Template which relates to a single post.

Worked like a charm! thank you guys for the support!!!!