给wordpress添加面包屑导航

什么是面包屑导航(BreadcrumbNavigation)?参见百度百科
面包屑可以在网站中起到导航的作用, 方便读者把握网站结构内容的同时,也便于搜索引擎进行索引. 如果一个网站存在面包屑, 在 Google 中看到的是路径索引, 而不是文章链接, 如下图.

面包屑导航在GOOGLE中的效果

面包屑导航在GOOGLE中的效果

面包屑导航可以让用户可以一级一级找到过来的路,方便返回,这样做的好处是增强用户体验,提高用户黏度。面包屑导航的大体格式就是 首页 » 分类一 » 分类二 » 当前所在页面。
Breadcrumb NavXTBreadcrumbs这两个插件都可以为wordpress添加面包屑导航,同时我们还可以添加以下代码实现面包屑导航:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<div class="dp-highlighter nogutter">
<div class="bar">
</div>

<ol class="dp-c" start="0">
<li class="alt">
<span><span><div id=</span><span class="string">"position"</span><span>>   </span></span>
</li>
<li>
<span>当前位置:<a href=</span><span class="string">"<?php bloginfo('url'); ?>"</span><span>><?php bloginfo('name'); ?></a> &raquo;   </span>
</li>
<li class="alt">
<span><?php   </span>
</li>
<li>
<span class="keyword">if</span><span>( is_single() ){   </span>
</li>
<li class="alt">
<span class="vars">$categorys</span><span> = get_the_category();   </span>
</li>
<li>
<span class="vars">$category</span><span> = </span><span class="vars">$categorys</span><span>[0];   </span>
</li>
<li class="alt">
<span class="func">echo</span><span>( get_category_parents(</span><span class="vars">$category</span><span>->term_id,true,' &raquo; ') );   </span>
</li>
<li>
<span>the_title();   </span>
</li>
<li class="alt">
<span>} </span><span class="keyword">elseif</span><span> ( is_page() ){   </span>
</li>
<li>
<span>the_title();   </span>
</li>
<li class="alt">
<span>} </span><span class="keyword">elseif</span><span> ( is_category() ){   </span>
</li>
<li>
<span>single_cat_title();   </span>
</li>
<li class="alt">
<span>} </span><span class="keyword">elseif</span><span> ( is_tag() ){   </span>
</li>
<li>
<span>single_tag_title();   </span>
</li>
<li class="alt">
<span>} </span><span class="keyword">elseif</span><span> ( is_day() ){   </span>
</li>
<li>
<span>the_time('Y年Fj日');   </span>
</li>
<li class="alt">
<span>} </span><span class="keyword">elseif</span><span> ( is_month() ){   </span>
</li>
<li>
<span>the_time('Y年F');   </span>
</li>
<li class="alt">
<span>} </span><span class="keyword">elseif</span><span> ( is_year() ){   </span>
</li>
<li>
<span>the_time('Y年');   </span>
</li>
<li class="alt">
<span>} </span><span class="keyword">elseif</span><span> ( is_search() ){   </span>
</li>
<li>
<span class="func">echo</span><span> </span><span class="vars">$s</span><span>.' 的搜索结果';   </span>
</li>
<li class="alt">
<span>}   </span>
</li>
<li>
<span>?>   </span>
</li>
<li class="alt">
<span></div>  </span>
</li>
</ol>
</div>
test Mini Entriestest 使用多说(duoshuo)评论框插件

  评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×