I have a category of events (A), it has 2 sub-categories(A1, A2). I need to list all its events grouped by sub-categories:
Category A
Category A1
Some description text
Coming events : blabla (these events are sorted by the location)
-------------------------------------------------------------------
Category A2
Some description text
Coming events : blabla
The default single category page does not display its child categories’ events, so I modified the file templates/templates/category-single.php:
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/>';
}
}
It displayed the events as I expected.
When I added this page into the navigation menu, I found it lost a CSS class “current-menu-item” which is helpful for me to highlight the current item in the menu.
Maybe I did something wrong or I should add/modify something somewhere. I’m totally clueless.I’m not very familiar with PHP5 and I’m new to WordPress.
Any help/suggestion is welcome! Thanks in advance.