有的wordpress主題模版則沒有。找到一個Breadcrumb Navigation麵包屑導航的代碼。分享一下。。。
$ p7 f- q5 S3 c" R- Q+ p u9 H. I* b; M1 H' n, \
9 V# ?* \0 j% b2 _3 }1、修改主題的functions.php文件中添加下面這段代碼:- # Breadcrumb
9 I0 |/ {( k/ n) Y; ]. K6 `) Q - function the_breadcrumb() {& k4 {" l- c$ d/ b R( _
- if (!is_home()) {
1 X7 l1 A/ P: E/ ~1 R+ g - echo '<a href="';
* _) P. Z7 b" d - echo get_option('home');( L6 A* n. u' F6 X! \! y y
- echo '">';
: j/ n( q# {) M% J+ [8 l - echo "Home";
' v* n( c. q0 l, [ - echo "</a> » ";
( ~2 c; N% [' I f( x4 D1 ^4 V. L7 _- J - if (is_category() || is_single()) {: p. m/ q5 D7 \" L" n. w
- single_cat_title();
3 [/ Z- |7 O$ O F1 q - if (is_single()) {
0 E& t" @" |$ Y$ z7 K& ]) D - the_category(', ');
, X5 Q3 h$ x5 I4 E5 X' q - echo " » ";
2 i1 v. R& n: D: T9 Z - the_title();
3 M$ x& i5 `+ H$ Z - }. S' Z* V# l& H$ R
- } elseif (is_page()) {
# a/ I5 [4 ?: i" a9 A - echo the_title();
$ ?, m1 _. M1 u8 f7 b5 s - }* }/ c# q- [% C
- elseif (is_tag()) {) D% h. q2 o, T( {8 d# Y/ N1 d
- echo 'Posts tagged with "';
7 A% w8 h9 n A: s" C - single_tag_title();# N+ R% `5 a3 B b' V" T* e8 f
- echo '"'; }
. Y& b1 ?) j/ g& W% x - elseif (is_day()) {echo "Archive for "; the_time(' F jS, Y');}
2 X" R0 m9 e; B7 @, `: R - elseif (is_month()) {echo "Archive for "; the_time(' F, Y');}
6 d! D; `2 k2 }- z0 |% u8 F. b, ]- K - elseif (is_year()) {echo "Archive for "; the_time(' Y');}* \: l0 ]% Y9 [4 a/ _; L
- elseif (is_author()) {echo "Author Archive";}
2 ^4 D9 i) S% ? - elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "Blog Archives";}2 i5 J1 N( L- I& Y3 j" d
- elseif (is_search()) {echo "Search Results";}6 w7 p( P; y& q
- }5 k9 C/ I c0 ~
- }% y2 u8 u; V" H
複製代碼 2、在頁面模板(category.php或single.php等)適當地方插入這一行:- <?php9 i! o0 q0 S p
- the_breadcrumb();! v0 R! d' D1 k4 {+ e8 S5 @
- ?>2 |) A5 ]; S- v- Q
複製代碼 |
|