Breadcrumbs in WordPress
I have a breadcrumb in my current WordPress theme and I want the breadcrumb Home not to be displayed on Home page because I get Home > Home.
How can I set the following rule: If on home page do not display the first "Home" word?
Thanks guys!
Here is the code from theme:
// Breadcrumb
function the_breadcrumb() {
global $post;
echo '<nav class="breadcrumb" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><ol>';
if (!is_home()) {
echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="';
echo get_option('home');
echo '" itemprop="url"><span itemprop="title">';
echo '<span itemprop="title"><strong>Home</strong></span>';
echo '</span></a></li>';
if (is_category() || is_single()) {
echo '<li itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">';
the_category(' </li><li itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> ');
if (is_single()) {
echo '</li><li itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">';
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 itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'" itemprop="url"><span itemprop="title">'.get_the_title($ancestor).'</span></a></li>';
}
echo $output;
echo '<li class="pag_actual" itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title"> '.$title.'</span></li>';
} else {
echo '<li class="pag_actual" itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title"><strong> '.get_the_title().'</strong></span></li>';
}
}
}
链接地址: http://www.djcxy.com/p/39192.html
上一篇: 定制Breadcrumbs NavXT
下一篇: WordPress中的面包屑