• Resolved natver

    (@natver)


    Hi! This is what I’m using for showing the category name:

    <?php
    	$event_id = get_the_ID();
    	$event_cats = get_the_terms($event_id, 'tribe_events_cat');
            $custom_field = get_field( 'custom_field', Tribe__Events__Main::TAXONOMY );
    	foreach ($event_cats as $category) {
    		echo '<p>' . $category->name . '</p>';
                    echo '<p>' . $custom_field . '</p>';
    	}
    ?>

    I also have ACF field input for the categories. Tried many different options to get the custom field from the category, but still do not get how to call it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter natver

    (@natver)

    I figured this out. I added a function in functions.php and then called it inside the template

    
    if ( class_exists('Tribe__Events__Main') ){
    	function tribe_get_color_categories ( $event_id = null ) {
    		if ( is_null( $event_id ) ) {
    			$event_id = get_the_ID();
    		}
    		$event_cats = '';
    		$term_list = wp_get_post_terms( $event_id, Tribe__Events__Main::TAXONOMY );
    		foreach( $term_list as $term_single ) {
    			$category_color_primary = get_field('event_category_color', $term_single);
    		}
    		if($category_colour_primary) {
    			echo 'style="color:';
    			echo $category_color_primary;
    			echo ' " ';
    		}
    	}
    }
    
    Thread Starter natver

    (@natver)

    Closing

    Hey @natver

    Thank you so much for sharing your solution with everyone!

    Kudos!
    Geoff

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘ACF field from category’ is closed to new replies.