';
// Open the breadcrumbs.
$html .= '
';
// Add Homepage link & separator (always present).
$html .= '' . esc_html( $args['home_title'] ) . '';
$html .= $separator;
// Post.
if ( is_singular( 'post' ) ) {
$category = get_the_category( $post->ID );
$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 .= '' . wp_strip_all_tags( 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 .= '' . wp_strip_all_tags( get_the_title( $parent ) ) . '';
$html .= $separator;
}
}
$html .= ' ' . wp_strip_all_tags( 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 .= '' . wp_strip_all_tags( $parent_title ) . '';
$html .= $separator;
$html .= ' ' . wp_strip_all_tags( get_the_title() ) . '';
} elseif ( is_singular() ) {
$post_type = get_post_type( $post->ID );
$post_type_object = get_post_type_object( $post_type );
$post_type_archive = get_post_type_archive_link( $post_type );
$html .= '' . wp_strip_all_tags( $post_type_object->labels->name ) . '';
$html .= $separator;
$html .= '' . wp_strip_all_tags( $post->post_title ) . '';
} elseif ( is_category() ) {
$parent = get_queried_object()->category_parent;
if ( 0 !== $parent ) {
$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', 'best-reloaded' ) . '';
} elseif ( is_home() ) {
$html .= '' . esc_html( get_the_title( get_option( 'page_for_posts' ) ) ) . '';
} // End if().
$html .= '
';
$html .= '
';
echo wp_kses_post( $html );
} // End if().
}
} // End if().
add_action( 'best_reloaded_do_before_main_content_row', 'best_reloaded_do_breadcrumbs' );