Get Event Tags to use in conditional
-
So new to Events Calendar. I found this function,
$tags = tribe_meta_event_tags();
that gets the tags attached to the events, but it echos out a list.I am looking for function that gets the event TAGS and then I can use this list for a conditional check and display individual icons based on the tag.
for example. Each event can have a tag of Game or Event. So I want to display an icon based on Game vs Event. Here is the code I came up with that does not work. See pseudo code below. Any help would be greatly appreciated. So need Event Calendar function to get the TAGS NOT CATEGORIES. Then use conditional to check if TAG is and display based on this tag. Also, using is_term() the correct one? I also found this one:
if ( has_term ( $id, TribeEvents::TAXONOMY, get_the_ID() ) ) { /* Do something... */ }
Pseudo Code Below I am trying:
function tribe_add_icon_to_event_title ( $post_title, $post_id ) { $tags = tribe_meta_event_tags(); if ( !empty( $tags ) ) { if ( is_term( 6 ) ) { $post_title = 'Game Icon- ' . $post_title; } else if( is_term( 7 ) ) { $post_title = 'Event Icon- ' . $post_title; } } return $post_title; } add_filter( 'the_title', 'tribe_add_icon_to_event_title ', 100, 2 );
Thanks!
- The topic ‘Get Event Tags to use in conditional’ is closed to new replies.