jdkahn
Forum Replies Created
-
Just noticed I missed out a closing bracket:
$categoryList = array(); foreach((get_the_category()) as $category) // build list of categories for this post { $categoryList[] = $category->cat_ID; } ?><ul><?php wp_list_categories("include=" . join(",", $categoryList)); // only show categories this post is in ?></ul><?phpHi Amber,
The quickest way for me to help might be for you to post the piece of code you’re using at the moment, and then I can propose changes.
Here’s an attempt at what you need though:
$categoryList = array(); foreach((get_the_category()) as $category) // build list of categories for this post { $categoryList[] = $category->cat_ID; } ?><ul><?php wp_list_categories("include=" . join(",", $categoryList); // only show categories this post is in ?></ul><?phpI admit that doesn’t actually use in_category! Had another look and this seemed closer.
Happy to actually write you the code if this still doesn’t make sense / work.
Hi Amber,
Looks like the way to do this is to loop through all the categories, and only show the ones that apply to this post.
You can test whether a post is in a category using the in_category function. Check out the examples at the end.
If that’s greek to you perhaps you could give an example of what you have now (code), and I might be able to suggest what to replace it with.
Hope that helps,
Jonathan