有的wordpress主題模版則沒有。找到一個Breadcrumb Navigation麵包屑導航的代碼。分享一下。。。
3 h% I6 o: d4 w: r1 H! e4 G- z, n5 [4 u$ X
0 S$ L& n3 u/ Z1 ~* v/ z# s
1、修改主題的functions.php文件中添加下面這段代碼:- # Breadcrumb5 x8 @% S! J6 {# ~: V
- function the_breadcrumb() {* Q. E9 n% A, U9 W/ s- g
- if (!is_home()) {
f" A- o* B6 g+ `% t - echo '<a href="';
& i9 m' T- W/ G' M: k+ M" ?6 g - echo get_option('home');
, I4 u* Z; O; C& }0 E9 |) v - echo '">';
. |4 K+ z0 U: B1 |% ]+ |* m! j - echo "Home"; U3 m7 y* \: a) _. f( t
- echo "</a> » ";! ^2 z: w9 q; y5 s. {, j3 N0 E$ J4 j% X
- if (is_category() || is_single()) {2 \$ d W8 z5 P1 C- ~1 l
- single_cat_title();
) u( t; {4 c2 Q/ ] ? - if (is_single()) {) [/ l$ z* \2 Q5 E. m
- the_category(', ');+ }& ?+ I& R. w. x
- echo " » ";
/ \; L" R! f' ?3 ?; C8 }6 ~ - the_title();' D# C3 N: v* L, F- l8 f
- }
% T3 H- u5 q! W! x/ J8 V - } elseif (is_page()) {
# E3 h8 v- u- h" N; m+ l6 U - echo the_title();
( Y+ u4 v) Z# I! B0 {5 O - }
# z; g: s- L$ a$ f l/ N - elseif (is_tag()) {9 f* I. H; x+ L; i" O
- echo 'Posts tagged with "';
9 C. z. z1 m8 c7 V - single_tag_title();
- }$ C) W% y" |3 q: e$ ] - echo '"'; }2 j7 _$ i! g* i/ U! z
- elseif (is_day()) {echo "Archive for "; the_time(' F jS, Y');}; r/ X4 N0 Y: x6 Z( _& h
- elseif (is_month()) {echo "Archive for "; the_time(' F, Y');}' S" z5 k9 E/ m9 d/ Q- o7 k
- elseif (is_year()) {echo "Archive for "; the_time(' Y');}
3 z9 U+ C9 H, i - elseif (is_author()) {echo "Author Archive";}
" V8 S* @6 N" e1 W - elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "Blog Archives";}# o4 ]5 Y( ?6 B! V6 m, o/ d P
- elseif (is_search()) {echo "Search Results";}
, Y" X8 T) X" p - }
! t- E6 p5 F6 c# u% U - }7 u7 S# i2 |; ?5 R9 o$ U
複製代碼 2、在頁面模板(category.php或single.php等)適當地方插入這一行:- <?php c3 E0 }6 ^) T7 u& ?; e9 I+ z" G
- the_breadcrumb();
! R6 h2 [. n- {1 R* {) U - ?>* R& r" Y( V" r
複製代碼 |
|