wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.
block_core_breadcrumbs_get_term_ancestors_items › WordPress Function
Od7.0.0
Przestarzałyn/a
› block_core_breadcrumbs_get_term_ancestors_items ( $term_id, $taxonomy )
| Parametry: (2) |
|
| Powrót: |
|
| Zdefiniowane na: |
|
| Codex: |
Generates breadcrumb items for hierarchical term ancestors.
For hierarchical taxonomies, retrieves and formats ancestor terms as breadcrumb links.Źródło
function block_core_breadcrumbs_get_term_ancestors_items( $term_id, $taxonomy ) {
$breadcrumb_items = array();
// Check if taxonomy is hierarchical and add ancestor term links.
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
$term_ancestors = get_ancestors( $term_id, $taxonomy, 'taxonomy' );
$term_ancestors = array_reverse( $term_ancestors );
foreach ( $term_ancestors as $ancestor_id ) {
$ancestor_term = get_term( $ancestor_id, $taxonomy );
if ( $ancestor_term && ! is_wp_error( $ancestor_term ) ) {
$breadcrumb_items[] = array(
'label' => $ancestor_term->name,
'url' => get_term_link( $ancestor_term ),
);
}
}
}
return $breadcrumb_items;
}