<?php if(is_front_page() || is_404()){ } else {?>
<div class=”breadcrumb”>
<div class=”container”>
<div class=”row”>
<div class=”col-12″>
<?php echo custom_breadcrumbs($page_ID); ?>
</div>
</div>
</div>
</div>
<?php } ?>
<?php
// Breadcrumbs
function custom_breadcrumbs($postId) {
// Get the query & post information
$post = get_post($postId);
$GLOBALS[‘post’] = $post;
$brd_str = ”;
// Do not display on the homepage
if ( !is_front_page()) {
$brd_str .= ‘<ul class=”breadcrumbs-list”>’;
//Home page
//$brd_str .= ‘<li class=”breadcrumb-item”><a class=”breadcrumb-item bread-home” href=”‘ . esc_url( site_url() ) . ‘” title=”Home”>Home</a></li>’;
if ( is_author() ){ // Auhor archive
// Get the author information
global $author;
$userdata = get_userdata( $author );
$user_firstname=get_user_meta($author,’first_name’,true);
$user_lastname=get_user_meta($author,’last_name’,true);
// Display author name
$brd_str .= ‘<li class=”item-current breadcrumb-item active item-current-‘ . $userdata->user_nicename . ‘ current”>’ . ‘Author : ‘ . $user_firstname . ‘</li>’;
}
else if ( (is_archive() || is_tax(‘gallery’)) && !is_category() && !is_tag() ) {
/*if(is_tax()){
$custom_tax_name = get_queried_object()->name;
$brd_str .= ‘<li class=”item-current breadcrumb-item item-archive active current”>’ . $custom_tax_name . ‘</li>’;
}*/
if(is_archive() || is_tax()){
$custom_tax_name = get_queried_object()->name;
$brd_str .= ‘<li class=”item-current breadcrumb-item item-archive active current”>’ . ucfirst($custom_tax_name) . ‘</li>’;
}
} else if ( is_single() ) {
$post_id = get_the_ID();
$post_type = get_post_type($post_id);
$post_type_obj = get_post_type_object( get_post_type($post_id) );
$posttypename = $post_type_obj->label;
if($post_type==’news’){
$brd_str .= ‘<li class=”current active breadcrumb-item item-cat item-custom-post-type-‘ . $post_type . ‘”><a href=”‘.site_url().’/news” class=”breadcrumb-item bread-home”>’ . $posttypename . ‘</a></li>’;
$categories = get_the_terms($post_id,’news-type’);
if(!empty($categories)){
if(!empty($categories[0])){
$cat_name = $categories[0]->name;
$cat_link = get_term_link($categories[0]->term_id);
$brd_str .= ‘<li class=”breadcrumb-item”>’.$cat_name.'</li>’;
}
}
global $post;
if ( $post->post_parent ) {
//$brd_str .= ‘<li class=”breadcrumb-item”><a class=”breadcrumb-item bread-home” href=”‘ .get_the_permalink($post->post_parent). ‘” title=”‘.get_the_title($post->post_parent).'”>’ . get_the_title($post->post_parent) . ‘</a></li>’;
}
} elseif($post_type==’tribe_events’){
$brd_str .= ‘<li class=”current active breadcrumb-item item-cat item-custom-post-type-‘ . $post_type . ‘”><a href=”‘.site_url().’/events” class=”breadcrumb-item bread-home”>’ . $posttypename . ‘</a></li>’;
$categories = get_the_terms($post_id,’tribe_events_cat’);
if(!empty($categories)){
if(!empty($categories[0])){
$cat_name = $categories[0]->name;
$cat_link = get_term_link($categories[0]->term_id);
$brd_str .= ‘<li class=”breadcrumb-item”>’.$cat_name.'</li>’;
}
}
global $post;
if ( $post->post_parent ) {
//$brd_str .= ‘<li class=”breadcrumb-item”><a class=”breadcrumb-item bread-home” href=”‘ .get_the_permalink($post->post_parent). ‘” title=”‘.get_the_title($post->post_parent).'”>’ . get_the_title($post->post_parent) . ‘</a></li>’;
}
} elseif($post_type==’post’){
$categories = get_the_category($post_id,’news’);
if(!empty($categories)){
if(!empty($categories[0])){
$cat_name = $categories[0]->name;
$cat_link = get_term_link($categories[0]->term_id);
$brd_str .= ‘<li class=”breadcrumb-item”><a class=”breadcrumb-item bread-home” href=”‘ . site_url() . ‘/news/” title=”‘.$cat_name.'”>’.$cat_name.'</a></li>’;
}
}
global $post;
if ( $post->post_parent ) {
//$brd_str .= ‘<li class=”breadcrumb-item”><a class=”breadcrumb-item bread-home” href=”‘ .get_the_permalink($post->post_parent). ‘” title=”‘.get_the_title($post->post_parent).'”>’ . get_the_title($post->post_parent) . ‘</a></li>’;
}
}
//$brd_str .= ‘<li class=”current active breadcrumb-item item-cat item-custom-post-type-‘ . $post_type . ‘”>’ . get_the_title() . ‘</li>’;
} else if ( is_category() ) { // Category page
$brd_str .= ‘<li class=”item-current breadcrumb-item item-cat active current”>’ . single_cat_title(”, false) . ‘</li>’;
} else if ( is_search() ){ // Search results
if(empty(get_search_query())){
$brd_str .= ‘<li class=”item-current breadcrumb-item active item-current-‘ . get_search_query() . ‘ current”>Search Results for ‘.get_search_query().'</li>’;
}else{
$brd_str .= ‘<li class=”item-current breadcrumb-item active item-current-‘ . get_search_query() . ‘ current”>Search Results for “’.get_search_query().’”</li>’;
}
} elseif ( is_page() ) {
if( $post->post_parent ){ // Standard page
// If child page, get parents
$anc = get_post_ancestors( $post->ID );
// Get parents in the right order
$anc = array_reverse($anc);
// Parent page loop
foreach ( $anc as $ancestor ) {
$parents .= ‘<li class=”breadcrumb-item”><a class=”bread-parent breadcrumb-item bread-parent-‘ . $ancestor . ‘” href=”‘ . get_permalink($ancestor) . ‘” title=”‘ . get_the_title($ancestor) . ‘”>’ . get_the_title($ancestor) . ‘</a></li>’;
}
$brd_str .= $parents;
$brd_str .= ‘<li class=”item-current active breadcrumb-item item-‘ . $post->ID . ‘ current”>’ . get_the_title() . ‘</li>’;
} else {
$brd_str .= ‘<li class=”item-current active breadcrumb-item item-‘ . $post->ID . ‘ current”>’ . get_the_title() . ‘</li>’;
}
} else if ( is_tag() ){
$term_id = get_query_var(‘tag_id’);
$taxonomy = ‘post_tag’;
$args = ‘include=’ . $term_id;
$terms = get_terms( $taxonomy, $args );
$get_term_id = $terms[0]->term_id;
$get_term_slug = $terms[0]->slug;
$get_term_name = $terms[0]->name;
// Display the tag name
$brd_str .= ‘<li class=”item-current active breadcrumb-item item-tag-‘ . $get_term_id . ‘ item-tag-‘ . $get_term_slug . ‘ current”>’ . $get_term_name . ‘</li>’;
} elseif ( is_day() ){ // Day archive
// Year link
$brd_str .= ‘<li class=”item-year breadcrumb-item item-year-‘ . get_the_time(‘Y’) . ‘”><a class=”bread-year bread-year-‘ . get_the_time(‘Y’) . ‘” href=”‘ . get_year_link( get_the_time(‘Y’) ) . ‘” title=”‘ . get_the_time(‘Y’) . ‘”>’ . get_the_time(‘Y’) . ‘ Archives</a></li>’;
// Month link
$brd_str .= ‘<li class=”item-month breadcrumb-item item-month-‘ . get_the_time(‘m’) . ‘”><a class=”bread-month bread-month-‘ . get_the_time(‘m’) . ‘” href=”‘ . get_month_link( get_the_time(‘Y’), get_the_time(‘m’) ) . ‘” title=”‘ . get_the_time(‘M’) . ‘”>’ . get_the_time(‘M’) . ‘ Archives</a></li>’;
// Day display
$brd_str .= ‘<li class=”item-current active breadcrumb-item item-‘ . get_the_time(‘j’) . ‘ current”>’ . get_the_time(‘jS’) . ‘ ‘ . get_the_time(‘M’) . ‘ Archives</li>’;
} else if ( is_month() ){ // Month Archive
// Year link
$brd_str .= ‘<li class=”item-year breadcrumb-item item-year-‘ . get_the_time(‘Y’) . ‘”><a class=”bread-year bread-year-‘ . get_the_time(‘Y’) . ‘” href=”‘ . get_year_link( get_the_time(‘Y’) ) . ‘” title=”‘ . get_the_time(‘Y’) . ‘”>’ . get_the_time(‘Y’) . ‘ Archives</a></li>’;
//$brd_str .= ‘<li class=”separator separator-‘ . get_the_time(‘Y’) . ‘”> ‘ . $separator . ‘ </li>’;
// Month display
$brd_str .= ‘<li class=”item-month breadcrumb-item item-month-‘ . get_the_time(‘m’) . ‘”>’ . get_the_time(‘M’) . ‘ Archives</li>’;
} else if ( is_year() ){ // Year archive
$brd_str .= ‘<li class=”item-current active breadcrumb-item item-current-‘ . get_the_time(‘Y’) . ‘ current”>’ . get_the_time(‘Y’) . ‘ Archives</li>’;
} /* elseif ( get_query_var(‘paged’) ){ // Paginated archives
$brd_str .= ‘<li class=”item-current breadcrumb-item item-current-‘ . get_query_var(‘paged’) . ‘ current”>’.__(‘Page’) . ‘ ‘ . get_query_var(‘paged’) . ‘</li>’;
} */ elseif ( is_404() ){ // 404 page
$brd_str .= ‘<li class=”current active”>’ . ‘Error 404’ . ‘</li>’;
} else{
$brd_str .= ‘<li class=”item-current active breadcrumb-item item-40 current”>’. get_the_title( get_option( ‘page_for_posts’ )) .'</li>’;
}
$brd_str .= ‘</ul>’;
}
return $brd_str;
}
function custom_languagee_url($code) {
if ( !is_front_page()) {
if(is_product_category()){
$term_id = get_queried_object()->term_id;
$id = icl_object_id($term_id, ‘product_cat’, false, $code );
$permalink = get_term_link( $id );
} elseif(is_page()){
$page_id = get_the_ID();
$id = icl_object_id($page_id, ‘page’, false, $code );
$permalink = get_the_permalink( $id );
} elseif(is_tax( ‘element’ )){
$term_id = get_queried_object()->term_id;
$id = icl_object_id($term_id, ‘product_cat’, false, $code );
$permalink = get_term_link( $id );
} elseif ( is_home() ) {
$page_id = get_option( ‘page_for_posts’ );
$id = icl_object_id($page_id, ‘page’, false, $code );
$permalink = get_the_permalink( $id );
} elseif ( is_single() ) {
$page_id = get_the_ID();
$id = icl_object_id($page_id, ‘post’, false, $code );
$permalink = get_the_permalink( $id );
} elseif ( is_product() ) {
$page_id = get_the_ID();
$id = icl_object_id($page_id, ‘product’, false, $code );
$permalink = get_the_permalink( $id );
} else{
$permalink = apply_filters( ‘wpml_permalink’, site_url() , $code );
}
}else{
$permalink = apply_filters( ‘wpml_permalink’, site_url() , $code );
}
return $permalink;
}