• Resolved dxladner

    (@dxladner)


    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!

    • This topic was modified 3 years, 9 months ago by dxladner.
Viewing 1 replies (of 1 total)
  • Thread Starter dxladner

    (@dxladner)

    So I have figured out how to accomplish this using standard WP functions: Was looking for More Events Calendar functions but none the less, here is what I came up with

    function tribe_add_start_time_to_event_title ( $post_title, $post_id ) {
     
    	$tags = get_the_tags($post_id);
    	if ( !empty( $tags ) ) {
    		if ( $tags[0]->name == 'Game' ) {
    			$post_title = 'Game Icon - ' . $post_title;
    		} 
    		else if( $tags[0]->name == 'Event' ) {
    			$post_title = 'Event Icon - ' . $post_title;
    		}
    	 }
       
    	return $post_title;
      }
      add_filter( 'the_title', 'tribe_add_start_time_to_event_title', 100, 2 );
Viewing 1 replies (of 1 total)
  • The topic ‘Get Event Tags to use in conditional’ is closed to new replies.