<?php
function wp_bac_breadcrumb() {
    $delimiter = '<span class="delimiter"> &gt; </span>';
    $delimiter1 = '';
            $main = '首页';
            $maxLength= 30;
    $arc_year = get_the_time('Y');
    $arc_month = get_the_time('F');
    $arc_day = get_the_time('d');
    $arc_day_full = get_the_time('l');
    $url_year = get_year_link($arc_year);
    $url_month = get_month_link($arc_year,$arc_month);
    if (!is_front_page()) {
        echo '<div class="breadcrumbs"><strong>当前位置：</strong>';
        global $post, $cat;
        $homeLink = get_option('home');
        echo '<a href="' . $homeLink . '">' . $main . '</a>' . $delimiter;  
		
		if( is_singular('detail') ){
			echo '<a href="'.get_post_type_archive_link('detail').'">爆料</a>' . $delimiter;
			echo ' ' . get_the_title(); 
		}elseif( is_singular('notice') ){
			echo '<a href="'.get_post_type_archive_link('notice').'">公告</a>' . $delimiter;
			echo ' ' . get_the_title(); 
		}elseif (is_single()) {
            $category = get_the_category();
            $num_cat = count($category);
			if($category[0]){
                echo get_category_parents($category[0],  true,' ' . $delimiter . ' ');
			}
                echo ' ' . get_the_title();
        }elseif(is_tax('mall')){
			single_term_title();
		}
		elseif(is_tax('shop')){
			single_term_title();
		}
		elseif(is_tax('detail_tag')){
			single_term_title();
		}elseif(is_post_type_archive('detail')){
			echo '爆料';
		}
		elseif(is_post_type_archive('notice')){
			echo '公告';
		}
        elseif (is_category()) {
            echo get_category_parents($cat, true,' ' . $delimiter1 . ' ') ;
        }
        elseif ( is_tag() ) {
            echo '标签: "' . single_tag_title("", false) . '"';
        }
        elseif ( is_day()) {
            echo '<a href="' . $url_year . '">' . $arc_year . '</a> ' . $delimiter . ' ';
            echo '<a href="' . $url_month . '">' . $arc_month . '</a> ' . $delimiter . $arc_day . ' (' . $arc_day_full . ')';
        }
        elseif ( is_month() ) {
            echo '<a href="' . $url_year . '">' . $arc_year . '</a> ' . $delimiter . $arc_month;
        }
        elseif ( is_year() ) {
            echo $arc_year;
        }
        elseif ( is_search() ) {
            echo '搜索结果: "' . get_search_query() . '"';
        }
        elseif ( is_page() && !$post->post_parent ) {
            echo get_the_title();
        }
        elseif ( is_page() && $post->post_parent ) {
            $post_array = get_post_ancestors($post);
            krsort($post_array); 
            foreach($post_array as $key=>$postid){
                $post_ids = get_post($postid);
                $title = $post_ids->post_title;
                echo '<a href="' . get_permalink($post_ids) . '">' . $title . '</a>' . $delimiter;
            }
            the_title();
        }
        elseif ( is_author() ) {
            global $author;
            $user_info = get_userdata($author);
            echo  '作者: ' . $user_info->display_name ;
        }
        elseif ( is_404() ) {
            echo  '404.';
        }
        else {
        }
       echo '</div>';
    }else{
		echo '<div class="breadcrumbs"><strong>当前位置：</strong>'.get_bloginfo('name').'</div>';
	}
}
?>