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) 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;
}
Expand full source code Collapse full source code View on Trac
Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |