• Resolved bdotmall

    (@bdotmall)


    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter bdotmall

    (@bdotmall)

    Something to add to this…

    Now that I’m using the code snippet above I’ve removed all the parent categories from my child events, the parent category page is working by showing all the child category events and my calendar is showing the correct color for each child event category.

    The “problem” I have now is when I filter the FullCalendar. When showing “All Categories” and any of the child category events only, everything is fine. The problem is when I filter on any of the parent categories – the calendar does not show any events since no event explicitly uses any of the parent category tags. I would like to be able to filter on any parent category and display all the child category events in the calendar.

    Thoughts?

    Hi,

    Glad you’re enjoying the plugins.

    The best way to run custom code snippets in an upgrade-safe way is to add them using a filter. Here’s an example of using a filter with WP FullCalendar:

    https://pastebin.com/3FPEMPdV

    It might be you can use code along these lines to drill down into child categories:

    https://wordpress.stackexchange.com/questions/17268/how-to-get-child-category-list-post-in-one-template

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display child categories on Category page’ is closed to new replies.