Sounds weird, but can you check if this code works:
$terms = get_the_terms( $post->ID, 'service' );
if ( $terms ) {
foreach ( $terms as $term ) {
$colour_scheme = get_field( 'colour_scheme', $term );
$svg_image = get_field( 'svg_image', $term );
// we check if the term is top-level term, in which case it does not have a parent
$parent = ( $term->parent == 0 ) ? $term : get_term( $term->parent, 'service' );
$parent_slug = $parent->slug;
$parent_desc = $parent->description;
}
}
I called the get_term()
directly, no need to fetch the term twice using get_term_by()
as well.