Display child categories on Category page
-
Hello,
First and foremost, I love this plugin! I’ve combined it with your WP FullCalendar plugin and my small non-profit team loves our little website.
One thing that I was unable to configure though was showing child categories while viewing a parent category page or event on the calendar. I wound up needing to tag both the parent and child category so users could see a “complete” list while viewing the parent category page (the website is for individual and group workouts under a parent “training program”). This worked OK for a while, until I realized that the category coloring on my FullCalendar was showing the color of the parent category and not the child categories (different colors). Once I removed the parent category from each event, the FullCalendar colors were displaying properly (showing only the color of the child category), but my parent category page did not show any of the child category events.
After much searching, I found this snippet of code below. I placed it in my templates/templates/category-single.php file and voila, my problem is more or less solved! But now I’m fearful of maintenance and upgrades to the Events Manager plugin itself. I’d love it if you guys who created the plugin could incorporate this functionality in some way, ideally through a setting – maybe a checkbox in the “Settings > Pages > Event Categories” with a checkbox that simply states “Show child categories”. Of course having more formatting options than what this code snippet provides would be fantastic too, but just having the ability to display child categories with their parent would be a great start.
global $EM_Category;
$arrChild = get_term_children($EM_Category->id, EM_TAXONOMY_CATEGORY);
$child_count = count($arrChild);if($child_count == 0)
echo $EM_Category->output_single();
else {
for($i=0; $i < $child_count; $i++){
$cat = new EM_Category($arrChild[$i]);
echo ‘<h2>’.$cat->name.'</h2>’;
echo $cat->output_single();
if($i < $child_count-1)
echo ‘<hr/>’;
}
}Again, many thanks for such a great plugin!
- The topic ‘Display child categories on Category page’ is closed to new replies.