Forum
Categories call
Sorry - this is such a basic thing, I assume I'm missing someplace where it's spelled out, but I've looked and can't find.
I have articles that have two different types of category - one for the topic of the article, one for the type of article - both have only one category for each type. How do I, when pulling the content out via perch_content_custom get the name and / or slug for the categories that have been allotted to that article?
So, for instance, I may wish to have a different icon depending on what type of article it is. At the moment, I can filter what articles I get by category, but can't see simply how to output each article's category onto the page.
You should be able to use the
<perch:categories>
tags from your main template.So what am I doing wrong here - I'm trying to get the category and assign it to a php variable so I can use it for a 'related content' call. The template used is one that purely has the <perch:categories> tags.
This returns the category correctly and prints it, but doesn't assign the value to the variable $category. If I run the following instead
it completely disappears from the page. It doesn't completely die - the footer is still there. But everything related to this code and the subsequent perch_content_custom calls using the variable do not print.
What does the variable contain at that point?
In the case of the first one, the variable contains nothing.
What does debug output for the page?
Nothing jumps out at me.
produces the following:
Then the subsequent call:
produces this:
Looks like you need to check your inputs
Thanks. I hadn't noticed that I needed to pull the slug, not the title - and I don't know why the variable was coming in with new line characters, but I've used trim() to strip them off and now it works.