';
// Add Homepage link & separator (always present)
$html .= '
' . $args['home_title'] . '';
$html .= $separator;
// Post
if ( is_singular( 'post' ) ) {
$category = get_the_category();
$category_values = array_values( $category );
$last_category = end( $category_values );
$cat_parents = rtrim( get_category_parents( $last_category->term_id, true, ',' ), ',' );
$cat_parents = explode( ',', $cat_parents );
foreach ( $cat_parents as $parent ) {
$html .= '
' . wp_kses( $parent, wp_kses_allowed_html( 'a' ) ) . '';
$html .= $separator;
}
$html .= '
' . esc_html( get_the_title() ) . '';
} elseif ( is_singular( 'page' ) ) {
if ( $post->post_parent ) {
$parents = get_post_ancestors( $post->ID );
$parents = array_reverse( $parents );
foreach ( $parents as $parent ) {
$html .= '
' . esc_html( get_the_title( $parent ) ) . '';
$html .= $separator;
}
}
$html .= '
' . esc_html( get_the_title() ) . '';
} elseif ( is_singular( 'attachment' ) ) {
$parent_id = $post->post_parent;
$parent_title = get_the_title( $parent_id );
$parent_permalink = esc_url( get_permalink( $parent_id ) );
$html .= '
' . esc_html( $parent_title ) . '';
$html .= $separator;
$html .= '
' . esc_html( get_the_title() ) . '';
} elseif ( is_singular() ) {
$post_type = get_post_type();
$post_type_object = get_post_type_object( $post_type );
$post_type_archive = get_post_type_archive_link( $post_type );
$html .= '
' . esc_html( $post_type_object->labels->name ) . '';
$html .= $separator;
$html .= '
' . $post->post_title . '';
} elseif ( is_category() ) {
$parent = get_queried_object()->category_parent;
if ( $parent !== 0 ) {
$parent_category = get_category( $parent );
$category_link = get_category_link( $parent );
$html .= '
' . esc_html( $parent_category->name ) . '';
$html .= $separator;
}
$html .= '
' . single_cat_title( '', false ) . '';
} elseif ( is_tag() ) {
$html .= '
' . single_tag_title( '', false ) . '';
} elseif ( is_author() ) {
$html .= '
' . get_queried_object()->display_name . '';
} elseif ( is_day() ) {
$html .= '
' . get_the_date() . '';
} elseif ( is_month() ) {
$html .= '
' . get_the_date( 'F Y' ) . '';
} elseif ( is_year() ) {
$html .= '
' . get_the_date( 'Y' ) . '';
} elseif ( is_archive() ) {
$custom_tax_name = get_queried_object()->name;
$html .= '
' . esc_html( $custom_tax_name ) . '';
} elseif ( is_search() ) {
$html .= '
Search results for: ' . get_search_query() . '';
} elseif ( is_404() ) {
$html .= '
' . __( 'Error 404', 'bloogs' ) . '';
} elseif ( is_home() ) {
$html .= '
' . esc_html( get_the_title( get_option( 'page_for_posts' ) ) ) . '';
}
$html .= '
';
$html = apply_filters( 'themetim_breadcrumbs_filter', $html );
echo wp_kses_post( $html );
}