|
有的wordpress主题模版则没有。找到一个Breadcrumb Navigation面包屑导航的代码。分享一下。。。
1、修改主题的functions.php文件中添加下面这段代码:- # Breadcrumb
- function the_breadcrumb() {
- if (!is_home()) {
- echo '<a href="';
- echo get_option('home');
- echo '">';
- echo "Home";
- echo "</a> » ";
- if (is_category() || is_single()) {
- single_cat_title();
- if (is_single()) {
- the_category(', ');
- echo " » ";
- the_title();
- }
- } elseif (is_page()) {
- echo the_title();
- }
- elseif (is_tag()) {
- echo 'Posts tagged with "';
- single_tag_title();
- echo '"'; }
- elseif (is_day()) {echo "Archive for "; the_time(' F jS, Y');}
- elseif (is_month()) {echo "Archive for "; the_time(' F, Y');}
- elseif (is_year()) {echo "Archive for "; the_time(' Y');}
- elseif (is_author()) {echo "Author Archive";}
- elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "Blog Archives";}
- elseif (is_search()) {echo "Search Results";}
- }
- }
复制代码 2、在页面模板(category.php或single.php等)适当地方插入这一行:- <?php
- the_breadcrumb();
- ?>
复制代码 |
|