I have a subpage (child page) as a parent page as well, but the page link not appear on breadcrumb. The breadcrumb structure should be "Home > About Us > Information > Title Page" instead of "Home > About Us > Title Page" .
How do I fix that? should I add a code to my current breadcrumb function?
And here is the breadcrumb function in my website:
/* ---------------------------------------------------------------------------------------------
Breadcrumb
------------------------------------------------------------------------------------------------ */
function get_breadcrumb() {
global $post;
echo '<a href="'.home_url().'" rel="nofollow">Home</a>';
echo ' / ';
if (is_category() || is_single()) {
the_category(' / ');
if (is_single()) {
echo ' / ';
the_title();
}
} elseif (is_page()) {
if($post->post_parent){
$anc = get_post_ancestors( $post->ID );
$title = get_the_title();
foreach ( $anc as $ancestor ) {
$output = '<a href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'">'.get_the_title($ancestor).'</a> /';
}
echo $output;
echo '<strong title="'.$title.'"> '.$title.'</strong>';
} else {
echo '<strong> '.get_the_title().'</strong>';
}
}
elseif (is_tag()) {single_tag_title();}
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";}
}
Thank you..
elseif( is_page() ){
$items = [];
$items[] = '<strong> '.get_the_title().'</strong>';
$page = &$post;
while( $page->post_parent ){
$items[] = '<a href="'.get_permalink($page->post_parent).'" title="'.get_the_title($page->post_parent).'">'.get_the_title($page->post_parent).'</a> /';
$page = get_post($page->post_parent);
}
$items = array_reverse($items);
echo implode('/', $items);
}
// FYI I recomend you to find dimox_breadcrumbs
, it has configured all you need already
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.