Setting first Event category
-
Hello,
I want to set a certain category as main category.
For that I made a custum Attribut #_ATT{Hauptkategorie}Then I hook into em_event_get_categories:
add_filter('em_event_get_categories','my_em_event_get_categories',99,2); function my_em_event_get_categories($categories, $EM_Event){ $Hauptkategorie = $EM_Event->event_attributes["Hauptkategorie"]; foreach($categories as $Key => $EM_Category){ if ( (strtoupper($EM_Category->name) === trim(strtoupper($Hauptkategorie)) ) || (strtoupper($EM_Category->slug) === trim(strtoupper($Hauptkategorie)) ) ) { // this should set my Main Category as first //$catTemp = $EM_Category; //unset($EM_Category); //array_unshift($categories, $catTemp); } } return $categories }
But this approach does not work because $categories ist an Object of Iterator.
Is there anyone who has an idea how to put the correctly detected Main Category as first Element in the Categories List?thanks for help
Frank
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Setting first Event category’ is closed to new replies.