This is a simple WordPress breadcrumbs generator.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php
function generate_breadcrumbs($post_id, $separator = ' > ' , $home = 30) {
//$home = icl_object_id($home,'page',false);
echo '<a href="'. get_permalink($home) .'" title="' . get_the_title($home) . '">' . get_the_title($home) . '</a>';
$ancestors = get_post_ancestors($post_id);
if ($ancestors) {
$ancestors = array_reverse($ancestors);
foreach ($ancestors as $id) {
echo $separator .'<a href="'. get_permalink($id) .'" title="' . get_the_title($id) . '">' . get_the_title($id) . '</a>';
}
}
if ($post_id != $home) {
echo $separator . get_the_title($post_id);
}
}
?> |
For a more complete function, i recommend Dimox’s function.