我已经将一个html模板集成到wordpress主题中。但是,没有得到正确的面包屑。
以下是ORIGINAL BREADCRUMB ......
我得到BREADCRUMB就像下面......
我的breadCrumb函数如下所示....在functions.php中
function my_breadcrumb()
{
if(!is_front_page())
{
echo '<a href="';echo get_option('home');echo '">'; echo "Home"; echo "</a>";
echo " ";
echo "<span class='skt-breadcrumbs-separator'> / </span>";
echo " ";
}
if(is_category() || is_single())
{
$category = get_the_category();
$ID = $category[0]->cat_ID;
echo get_category_parents($ID, TRUE, ' / ', FALSE );
}
if(is_single() || is_page())
{
echo "<span>"; the_title(); echo "</span>";
}
if(is_tag())
{
single_tag_title('',FALSE);
}
if(is_404())
{
echo "404 - Page not Found";
}
if(is_search())
{
echo "Search";
}
if(is_year())
{
echo get_the_time('Y');
}
echo "";
}
NEWS菜单项是COMPANY菜单项的子菜单......
提前致谢。
答案 0 :(得分:1)
试试这个:
function the_breadcrumb() {
global $post;
echo '<ul id="breadcrumbs">';
if (!is_home()) {
echo '<li><a href="';
echo get_option('home');
echo '">';
echo '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>';
}
echo $output;
echo '<strong title="'.$title.'"> '.$title.'</strong>';
} else {
echo '<li><strong> '.get_the_title().'</strong></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>';}
echo '</ul>';
}
您的功能不是寻找子页面。