function the_breadcrumb() {
if (!is_home()) {
echo '<a href="'. get_option('home').'" >Home</a> / ';

if (is_category() || is_single()) {
the_category('title_li=');
if (is_single()) {
the_title();
}
}
elseif (is_page()) {

global $post;
// Check if page is a child page (any level)
if ($post->ancestors) {

$reverse_pages_ids = $post->ancestors;

$pages_ids = array_reverse($reverse_pages_ids);

foreach($pages_ids as $key => $values){
echo '<a href="'.get_permalink($values).'" >'.get_the_title($values). '</a> / ';
}
}
}

the_title();
}
}

Advertisements