Breadcrumbs Include Current Post Custom Tax?

Hybrid Core (framework) 2 posts 2 voices

  1. Is it possible to include the current tax of the single post you’re on.

    e/g i have a post type called.. cassio-treatments each one of those is categorised within the custom tax treatment-category which has its own ‘home page’ at taxonomy-treatment-category.php

    Below is what i currently have in my functions, i think i need to use wp_get_post_terms but just need to pull one in and place it as a link below?

    if ( is_singular( 'cassio-treatments' )  ) {
    		
    				$items = array();
    				$items[] = '<a href="' . home_url('') . '>Home</a>';
    				$items[] = '<a href="' . home_url('/?p=50') . '>Treatments Custom </a>';
    				$items[] = ’The Custom Tax Home Page of this Post? e/g taxonomy-treatment-category.php';
    				$items[] = single_post_title( '', false );
    				
    				
    			}
  2. Breadcrumb Trail has a built-in way of doing this. However, you can’t use that method because you’re custom-coding the items.

    Here’s a basic version of doing it. However, it doesn’t account for parent terms:

    // Get the post categories.
    $terms = get_the_terms( get_queried_object_id(), 'treatment-category' );
    
    // Check that categories were returned.
    if ( $terms && ! is_wp_error( $terms ) ) {
    
    	// Sort the terms by ID and get the first category.
    	$terms = wp_list_sort( $terms, 'term_id' );
    
    	$term = get_term( $terms[0], $taxonomy );
    
    	// Add the category archive link to the trail.
    	$items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_term_link( $term, 'treatment-category' ) ), $term->name );
    }