wordpress面包屑导航(本站倾情)

面包屑导航也可以叫做“当前位置导航”,可以让读者清晰的了解自己所在的网页位置,对SEO也有好处。乌徒帮将自己的面包屑导航扒出来,希望对朋友们有帮助。

// 面包屑导航  [payfor price="3"]function the_place(){  $homeName = get_bloginfo('name');// 可以将首页替换成某个关键字  ?>  <a href="http://www.weixing.io/" rel="external nofollow"  title="去  首页" rel="home"> › cat_ID;   $category = get_category($cat_id);   $output = '';$seperator = ' › ';   while($category->parent){    $category = get_category($category->parent);    $output = 'term_id).'" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  title="'.$category->cat_name.'">'.$category->cat_name.''.$seperator.$output;   }   echo $output;   single_cat_title();  endif;  if(is_archive()){   if(is_year())echo get_the_date('Y年');   if(is_month())echo get_the_date('Y年n月');   if(is_day())echo get_the_date('Y年n月d日');  }  if(is_tag())echo single_tag_title('',false);  if(is_author()):the_post();echo '作者:';the_author();rewind_posts();endif;  if(is_search() && isset($_GET['s']) && $_GET['s'] != '')echo '搜索:'.$_GET['s'];  if(is_page()):   global $post;$parent = $post;   while($parent->post_parent){    $parent = get_post($parent->post_parent);    echo 'ID).'" rel="external nofollow" >'.$parent->post_title.' › ';   }   the_title();  endif;  if(is_single()):   if(is_attachment()):    global $post;    $parent = get_post($post->post_parent);    $parent_title = $parent->post_title;    $parent_id = $parent->ID;    $parent_url = get_permalink($parent_id);    $categories = get_the_category($parent_id);    rewind_posts();    $output = '';$seperator = ' › ';$category = $categories[0];$category->parent = $category->term_id;    do{     $category = get_category($category->parent);     $output = 'term_id).'" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  title="'.$category->cat_name.'">'.$category->cat_name.''.$seperator.$output;    }while($category->parent);    $output .= ''.$parent_title.''.$seperator;    echo $output;    the_title();   else :    $categories = get_the_category();    $output = '';$seperator = ' › ';$t = '';    if(count($categories) > 1 && 0){ // 如果需要使用到多栏目列出,去掉&& 0     foreach($categories as $category):      $category->parent = $category->term_id;      do{       $category = get_category($category->parent);       $output = 'term_id).'" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  title="'.$category->cat_name.'">'.$category->cat_name.''.$seperator.$output;      }while($category->parent);      $t .= ' & '.substr($output,0,-10);$output = '';     endforeach;     $output = ' ( '.substr($t,3).' ) '.$seperator;    }else{     $category = $categories[0];     do{      $output = 'term_id).'" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  title="'.$category->cat_name.'">'.$category->cat_name.''.$seperator.$output;      $category = get_category($category->parent);     }while($category->term_id);    }    echo $output;    the_title();   endif;  endif; }[/payfor]

前台调用时,使用the_place()函数即可。

0

评论0

请先

没有账号? 注册  忘记密码?

社交账号快速登录