Permalink
Browse files

Updated breadcrumb

  • Loading branch information...
awmartin committed Feb 4, 2016
1 parent 09e664a commit 31f5c8ac02aabfb9498adc7b25929c7cec862ff7
Showing with 40 additions and 4 deletions.
  1. +40 −4 null.breadcrumb.php
View
@@ -2,13 +2,49 @@
function NullBreadcrumb() {
$tr = '<ul class="breadcrumb">';
$category_list = trim(get_the_category_list( ', ' ));
if ($category_list != "") {
$tr = $tr."<li>&middot; ".get_the_category_list( ', ' )."</li>";
if (is_post()) {
$tr = $tr.list_breadcrumb_categories();
} else if (is_page()) {
$tr = $tr.list_breadcrumb_hierarchy();
}
$tr = $tr.'<li>&middot; <a href="'.get_site_url().'">Home</a></li>';
$tr = $tr.crumb(home_link());
$tr = $tr.'</ul>';
return $tr;
}
function crumb($content) {
return NullTag("li", "&middot; ".$content);
}
function home_link() {
return NullLink("Home", get_site_url());
}
function list_breadcrumb_categories() {
$category_list = trim(get_the_category_list( ', ' ));
if ($category_list != "") {
return crumb($category_list);
} else {
return "";
}
}
function list_breadcrumb_hierarchy() {
$id = get_the_ID();
$parent_id = get_post_field('post_parent', $id);
if ($parent_id > 0) {
$parent_title = get_the_title($parent_id);
$parent_url = get_permalink($parent_id);
return crumb(NullLink($parent_title, $parent_url));
} else {
return '';
}
}
?>

0 comments on commit 31f5c8a

Please sign in to comment.