中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

如何制作網(wǎng)站面包屑導(dǎo)航

2018-11-01    來源:學(xué)做網(wǎng)站論壇

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用

什么是網(wǎng)站面包屑導(dǎo)航

相信很多初學(xué)建站的學(xué)員對網(wǎng)站菜單導(dǎo)航并不陌生,但對于網(wǎng)站面包屑導(dǎo)航卻知之甚少,那么什么是網(wǎng)站面包屑導(dǎo)航呢?就是網(wǎng)站首頁之外的主題內(nèi)容上面的階梯形導(dǎo)航。如下圖:
wordpress網(wǎng)站面包屑導(dǎo)航制作

面包屑導(dǎo)航制作方法

從網(wǎng)站面包屑導(dǎo)航的作用來看,它對于我們做網(wǎng)站SEO優(yōu)化有著相當(dāng)?shù)淖饔。那么如何做網(wǎng)站時(shí)能夠制作出網(wǎng)站面包屑導(dǎo)航呢?方法如下:

  1. 進(jìn)入自己做網(wǎng)站的后臺,找到主題下面的編輯按鈕;wordpress網(wǎng)站面包屑導(dǎo)航制作"
  2. 將以下的代碼復(fù)制到模板函數(shù)functions.php里;
    
    
    //面包屑
    function wheatv_breadcrumbs() {
    ? $delimiter = ' > ';
    ? $name = '首頁';
    ?
    ? if ( !is_home() ||!is_front_page() || is_paged() ) {
    ?
    ?   global $post;
    ?   $home = home_url();
    ?   echo '<a href="' . $home . '"  class="gray">' . $name . '</a> ' . $delimiter . ' ';
    ?
    ?   if ( is_category() ) {
    ?     global $wp_query;
    ?     $cat_obj = $wp_query->get_queried_object();
    ?     $thisCat = $cat_obj->term_id;
    ?     $thisCat = get_category($thisCat);
    ?     $parentCat = get_category($thisCat->parent);
    ?     if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
    ?     echo single_cat_title();
    ?
    ?   } elseif ( is_day() ) {
    ?     echo '<a href="' . get_year_link(get_the_time('Y')) . '"  class="gray">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
    ?     echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '"  class="gray">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
    ?     echo get_the_time('d');
    ?
    ?   } elseif ( is_month() ) {
    ?     echo '<a href="' . get_year_link(get_the_time('Y')) . '"  class="gray">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
    ?     echo get_the_time('F');
    ?
    ?   } elseif ( is_year() ) {
    ?     echo get_the_time('Y');
    ?
    ?   } elseif ( is_single() ) {
    ?     $cat = get_the_category(); $cat = $cat[0];
    ?     echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
    ?     echo the_title();
    ?
    ?   } elseif ( is_page()||!$post->post_parent ) {
    ?     the_title();
    ?
    ?   } elseif ( is_page()||$post->post_parent ) {
    ?     $parent_id  = $post->post_parent;
    ?     $breadcrumbs = array();
    ?     while ($parent_id) {
    ?       $page = get_page($parent_id);
    ?       $breadcrumbs[] = '<a href="http://www.frontopen.com/wp-admin/ . get_permalink($page->ID) . "  class="gray">' . get_the_title($page->ID) . '</a>';
    ?       $parent_id  = $page->post_parent;
    ?     }
    ?     $breadcrumbs = array_reverse($breadcrumbs);
    ?     foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';
    ?     the_title();
    ?
    ?   } elseif ( is_search() ) {
    ?     echo get_search_query();
    ?
    ?   } elseif ( is_tag() ) {
    ?     echo single_tag_title();
    ?
    ?   } elseif ( is_author() ) {
    ?      global $author;
    ?     $userdata = get_userdata($author);
    ?     echo '由'.$userdata->display_name.'發(fā)表';
    ?
    ?   } elseif ( is_404() ) {
    ?     echo '404 錯(cuò)誤';
    ?   }
    ?
    ?   if ( get_query_var('paged') ) {
    ?     if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
    ?     echo '第' . ' ' . get_query_var('paged').' 頁';
    ?     if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
    ?   }
    ? }else{
    ?   echo $name;
    ? }
    }
  3. 在需要調(diào)用面包屑導(dǎo)航頁面的合適位置添加以下代碼:
    
    
    <?php wheatv_breadcrumbs(); ?>

就這樣二步,我們就可以在自己做網(wǎng)站時(shí),給自己的wordpress網(wǎng)站上添加面包屑導(dǎo)航了。

標(biāo)簽: isp seo 代碼 建站

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:學(xué)習(xí)仿站如何更換FLASH文件,如何仿站

下一篇:如何在自己網(wǎng)站設(shè)置屏蔽右鍵防復(fù)制