astra_breadcrumb_get_term_parents( int $parent_id = '', object|string $taxonomy = '', string $delimiter = '/' )

Searches for term parents of hierarchical taxonomies.


Description


Parameters

$parent_id

(int) (Optional) The ID of the first parent.

Default value: ''

$taxonomy

(object|string) (Optional) The taxonomy of the term whose parents we want.

Default value: ''

$delimiter

(string) (Optional) The separator.

Default value: '/'


Return

(string) $html String of links to parent terms.


Source

File: addons/advanced-headers/classes/astra-breadcrumbs.php

	function astra_breadcrumb_get_term_parents( $parent_id = '', $taxonomy = '', $delimiter = '/' ) {
		$html    = array();
		$parents = array();
		if ( empty( $parent_id ) || empty( $taxonomy ) ) {
			return $parents;
		}
		while ( $parent_id ) {
			$parent    = get_term( $parent_id, $taxonomy );
			$parents[] = '<span class="ast-breadcrumbs-link-wrap" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><a itemprop="item" rel="v:url" property="v:title" href="' . esc_url( get_term_link( $parent, $taxonomy ) ) . '" title="' . esc_attr( $parent->name ) . '">' . $parent->name . '</a></span>';
			$parent_id = $parent->parent;
		}
		if ( $parents ) {
			$parents = array_reverse( $parents );
		}

		return $parents;
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.