我对面包屑在我的网站上与bbpress论坛合作有一个问题。我尝试了几种不同的方法来克服这一问题&;我认为一个简单的解决方案是,如果帖子类型=论坛,那么该页面的面包屑应该是主页>论坛。
我尝试将其集成到我的breadcrumb函数php代码段中,但没有任何乐趣,有人能告诉我我做错了什么吗?
<?php
function the_breadcrumb() {
global $post;
$post_type = $post->post_type;
echo \'<ul id="breadcrumbs">\';
if (!is_home()) {
echo \'<li><a href="\';
echo get_option(\'home\');
echo \'">\';
echo \'<i class="ts-awesome-home" style="font-size:14px;letter-spacing: 2px;"></i> Home\';
echo \'</a></li><li class="separator"> / </li>\';
if (is_category() || is_single()) {
echo \'<li>\';
the_category(\' </li><li class="separator"> / </li><li> \');
if (is_single()) {
echo \'</li><li class="separator"> / </li><li>\';
the_title();
echo \'</li>\';
}
} elseif (is_page()) {
if($post->post_parent){
$anc = get_post_ancestors( $post->ID );
$title = get_the_title();
foreach ( $anc as $ancestor ) {
$output = \'<li><a href="\'.get_permalink($ancestor).\'" title="\'.get_the_title($ancestor).\'">\'.get_the_title($ancestor).\'</a></li> <li class="separator">/</li>\'.$output;
}
echo $output;
echo \'<span title="\'.$title.\'"> \'.$title.\'</span>\';
} else {
echo \'<li><span> \'.get_the_title().\'</span></li>\';
}
}
}
elseif (is_tag()) {single_tag_title();}
elseif (is_day()) {echo"<li>Archive for "; the_time(\'F jS, Y\'); echo\'</li>\';}
elseif (is_month()) {echo"<li>Archive for "; the_time(\'F, Y\'); echo\'</li>\';}
elseif (is_year()) {echo"<li>Archive for "; the_time(\'Y\'); echo\'</li>\';}
elseif (is_author()) {echo"<li>Author Archive"; echo\'</li>\';}
elseif (isset($_GET[\'paged\']) && !empty($_GET[\'paged\'])) {echo "<li>Blog Archives"; echo\'</li>\';}
elseif (is_search()) {echo"<li>Search Results"; echo\'</li>\';}
elseif (is_post_type(\'forum\') && is_post_type(\'post\') && is_post_type(\'topic\') && is_post_type(\'reply\')){
echo"<li>FORUM BREADCRUMBS"; echo\'</li>\';
}
echo \'</ul>\';
}
?>
谢谢你