/home/techb158/public_html/wp-content/themes/engitech/inc/frontend/page-header
Edit: /home/techb158/public_html/wp-content/themes/engitech/inc/frontend/page-header/breadcrumbs.php (9109B)
';
// Front page
if ( is_front_page() ) {
$breadcrumb .= '
' . esc_html__('Home', 'engitech') . ''; //get_bloginfo( 'name' )
} else {
$breadcrumb .= '
' . esc_html__('Home', 'engitech') . ''; //get_bloginfo( 'name' )
}
// Blog archive
if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ) {
$blog_page_id = get_option( 'page_for_posts' );
if ( is_home() ) {
$breadcrumb .= '
' . get_the_title( $blog_page_id ) . '';
} else if ( is_category() || is_tag() || is_author() || is_date() || is_singular( 'post' ) ) {
$breadcrumb .= '
' . get_the_title( $blog_page_id ) . '';
}
}
// Category, tag, author and date archives
if ( is_archive() && ! is_tax() && ! is_post_type_archive() ) {
$breadcrumb .= '
';
// Title of archive
if ( is_category() ) {
$breadcrumb .= single_cat_title( '', false );
} else if ( is_tag() ) {
$breadcrumb .= single_tag_title( '', false );
} else if ( is_author() ) {
$breadcrumb .= get_the_author();
} else if ( is_date() ) {
if ( is_day() ) {
$breadcrumb .= get_the_time( 'F j, Y' );
} else if ( is_month() ) {
$breadcrumb .= get_the_time( 'F, Y' );
} else if ( is_year() ) {
$breadcrumb .= get_the_time( 'Y' );
}
}
$breadcrumb .= '';
}
// Posts
if ( is_singular( 'post' ) ) {
$post_cats = get_the_category();
if ( !empty($post_cats) ) {
$breadcrumb .= '
' . $post_cats[0]->name . '';
}
// Post title
$breadcrumb .= '
' . get_the_title() . '';
}
// Pages
if ( is_page() && ! is_front_page() ) {
$post = get_post( get_the_ID() );
// Page parents
if ( $post->post_parent ) {
$parent_id = $post->post_parent;
$crumbs = array();
while ( $parent_id ) {
$page = get_page( $parent_id );
$crumbs[] = '
' . get_the_title( $page->ID ) . '';
$parent_id = $page->post_parent;
}
$crumbs = array_reverse( $crumbs );
foreach ( $crumbs as $crumb ) {
$breadcrumb .= '
' . $crumb . '';
}
}
// Page title
$breadcrumb .= '
' . get_the_title() . '';
}
// Attachments
if ( is_attachment() ) {
// Attachment parent
$post = get_post( get_the_ID() );
if ( $post->post_parent ) {
$breadcrumb .= '
' . get_the_title( $post->post_parent ) . '';
}
// Attachment title
$breadcrumb .= '
' . get_the_title() . '';
}
// Search
if ( is_search() ) {
$breadcrumb .= '
' . esc_html__( 'Search', 'engitech' ) . '';
}
// 404
if ( is_404() ) {
$breadcrumb .= '
' . esc_html__( '404', 'engitech' ) . '';
}
// Custom Post Type Archive
if ( is_post_type_archive() ) {
$breadcrumb .= '
' . post_type_archive_title( '', false ) . '';
}
// Custom Taxonomies
if ( is_tax() ) {
// Get the post types the taxonomy is attached to
$current_term = get_queried_object();
$attached_to = array();
$post_types = get_post_types();
foreach ( $post_types as $post_type ) {
$taxonomies = get_object_taxonomies( $post_type );
if ( in_array( $current_term->taxonomy, $taxonomies ) ) {
$attached_to[] = $post_type;
}
}
// Post type archive link
$output = false;
foreach ( $attached_to as $post_type ) {
$cpt_obj = get_post_type_object( $post_type );
if ( ! $output && get_post_type_archive_link( $cpt_obj->name ) ) {
$breadcrumb .= '
' . $cpt_obj->labels->singular_name . '';
$output = true;
}
}
// Term title
$breadcrumb .= '
' . single_term_title( '', false ) . '';
}
// Custom Post Types
if ( is_single() && get_post_type() != 'post' && get_post_type() != 'attachment' ) {
$cpt_obj = get_post_type_object( get_post_type() );
// Cpt archive
if ( get_post_type_archive_link( $cpt_obj->name ) ) {
// Custom portfolio archive page link
$archive_link = '';
if ( 'ot_portfolio' == get_post_type() && engitech_get_option('portfolio_archive') == 'archive_custom' ) {
$archive_link = get_page_link( engitech_get_option('archive_page_custom') );
} else {
$archive_link = get_post_type_archive_link( $cpt_obj->name );
}
$breadcrumb .= '
' . $cpt_obj->labels->singular_name . '';
}
// Is cpt hierarchical like pages or posts?
if ( is_post_type_hierarchical( $cpt_obj->name ) ) {
// Like pages
// Cpt parents
$post = get_post( get_the_ID() );
if ( $post->post_parent ) {
$parent_id = $post->post_parent;
$crumbs = array();
while ( $parent_id ) {
$page = get_page( $parent_id );
$crumbs[] = '
' . get_the_title( $page->ID ) . '';
$parent_id = $page->post_parent;
}
$crumbs = array_reverse( $crumbs );
foreach ( $crumbs as $crumb ) {
$breadcrumb .= '
' . $crumb . '';
}
}
} else {
// Like posts
// Get cpt taxonomies
$cpt_taxes = get_object_taxonomies( $cpt_obj->name );
if ( $cpt_taxes && is_taxonomy_hierarchical( $cpt_taxes[0] ) ) {
// Other taxes attached to the cpt could be hierachical, so need to look into that.
$cpt_terms = get_the_terms( get_the_ID(), $cpt_taxes[0] );
if ( is_array( $cpt_terms ) ) {
$output = false;
foreach( $cpt_terms as $cpt_term ) {
if ( ! $output ) {
$breadcrumb .= '
' . $cpt_term->name . '';
$output = true;
}
}
}
}
}
// Cpt title
$breadcrumb .= '
' . get_the_title() . '';
}
// Close list
$breadcrumb .= '' . $list_style . '>';
// Ouput
return $breadcrumb;
}
}
if ( ! function_exists( 'engitech_breadcrumbs' ) ) {
function engitech_breadcrumbs (){
if( engitech_get_option('breadcrumbs') && !is_front_page() ){ echo engitech_get_breadcrumbs(); } ?>