Last active
September 23, 2015 09:47
-
-
Save Pebblo/b9e0ced7289bd6331695 to your computer and use it in GitHub Desktop.
Output an events first cateory name and slug using the EE_Term object.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// The Event ID. | |
$event_id = 42; | |
//Pull the event object using the ID. | |
$event = EEM_Event::instance()->get_one_by_ID($event_id); | |
//Check we have an instance of an EE_Event | |
if ( $event instanceof EE_Event ) { | |
//Debug | |
//d($event); | |
//Pull the first EE_Term associated with the event. | |
$first_event_cat = $event->first_event_category(); | |
//Check we have an instance of EE_Term | |
if ( $first_event_cat instanceof EE_Term ) { | |
//Debug | |
//d($first_event_cat); | |
/* Now we have an EE_Term object for that event */ | |
/* We can output values using the object */ | |
echo $first_event_cat->name(); | |
echo "</br>"; | |
echo $first_event_cat->slug(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment