Display Taxonomy Term Meta
Display the Term Meta for a taxonomy term when looping through a post. Displays first term’s meta data
// Add Shortcode function get_resource_category_icon() { $terms = get_the_terms( get_the_ID(), 'resource_category'); // we will use the first term to load ACF data from if( !empty($terms) ) { if ( ! is_wp_error( $terms ) ) { $term = array_pop($terms); $custom_field = get_field('resource_category_icon', $term ); if(get_field('resource_category_icon', $term )) { return $custom_field; } else { // Display global resource icon from options page if custom icon doesn't exist on the Taxonomy Edit page. $global_icon = get_field('resource_library_default_icon', 'option'); return $global_icon; } } else { // Global Default Feild for Resource Library on Options Page (Fetch Options) $global_icon = get_field('resource_library_default_icon', 'option'); return $global_icon; } } else { $global_icon = get_field('resource_library_default_icon', 'option'); return $global_icon; } } add_shortcode( 'resource_category_icon', 'get_resource_category_icon' );