有的wordpress主題模版則沒有。找到一個Breadcrumb Navigation麵包屑導航的代碼。分享一下。。。
6 e+ U: `! V4 V! B) V6 O9 H* Q! M4 d: @+ P# h
# x6 a) Q1 F1 D& H. a/ N1、修改主題的functions.php文件中添加下面這段代碼:- # Breadcrumb
" F' g5 |6 t1 f% v0 m* Q4 O4 { - function the_breadcrumb() {
) _) y |& Z# M - if (!is_home()) {
8 f' D2 s; x1 A) j, f- E - echo '<a href="';( A5 D: {8 o( m" {
- echo get_option('home');: A- Y& s6 T/ E7 _ J
- echo '">';' t" e' O" p- {* X; V
- echo "Home";/ z# _0 e( ?7 _* ^; S
- echo "</a> » ";
% o8 S6 E3 b- e- ^, D I# }5 ]5 g - if (is_category() || is_single()) {
: i% b- ?; Z T' h* U2 G - single_cat_title();* K( E; F3 s1 _2 }: n
- if (is_single()) {' Y' m+ H3 o( O( z
- the_category(', ');! a; r) I/ W( ]$ I
- echo " » ";1 H, F. r% [# B
- the_title();! d/ I3 @) H" u! p+ u
- }
5 G; S- t3 n; j9 K - } elseif (is_page()) {
! w6 O) @2 A" C - echo the_title();2 U1 j" U6 P+ J
- }4 ?1 [5 Y" X! Y* j4 M$ D
- elseif (is_tag()) {/ S: F) W8 l C* I$ H
- echo 'Posts tagged with "';* b* t, n5 b& r6 q7 {% i
- single_tag_title();
$ X( ?: C* w' } x3 _ - echo '"'; }
; X& v+ P# c" L v( f! X/ @ - elseif (is_day()) {echo "Archive for "; the_time(' F jS, Y');}
" X. p4 Z* c. R; a - elseif (is_month()) {echo "Archive for "; the_time(' F, Y');}, @5 S; K3 j- P* K* Z* X3 M
- elseif (is_year()) {echo "Archive for "; the_time(' Y');}
8 a8 r; G B( n: P6 U v9 k - elseif (is_author()) {echo "Author Archive";}
: ?( [- b. i+ W# Y, G9 r2 E* a& a1 J - elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "Blog Archives";}$ g( n4 P( K6 Y/ t* Z; G
- elseif (is_search()) {echo "Search Results";}
6 s* q7 p1 c" P9 p+ ~, W7 w8 J6 l - }8 Q7 e0 e, M0 |/ @0 Y3 I
- }
/ Q: f3 e0 G3 s# e0 ~! A
複製代碼 2、在頁面模板(category.php或single.php等)適當地方插入這一行:- <?php' w& [, }' Y8 O; ~$ t3 S ^+ a8 v
- the_breadcrumb();
0 e. Q* {- W) o# S' F" v. r - ?>( S% l9 m8 ^( k/ c* p6 s ?( I
複製代碼 |
|