';
// main breadcrumbs lead to homepage
if (!is_single()) {
echo 'You are here: ';
}
echo '
' . '' . $home . '' . '' . $delimiter . ' ';
// if blog page exists
if (get_page_by_path('blog')) {
if (!is_page('blog')) {
echo '
' . 'Blog' . $delimiter . ' ';
}
}
if (is_category()) {
$thisCat = get_category(get_query_var('cat'), false);
if ($thisCat->parent != 0) {
$category_link = get_category_link($thisCat->parent);
echo '
' . '' . get_cat_name($thisCat->parent) . '' . '' . $delimiter . ' ';
}
$category_id = get_cat_ID(single_cat_title('', false));
$category_link = get_category_link($category_id);
echo '
' . '' . single_cat_title('', false) . '' . '';
}
elseif (is_single() && !is_attachment()) {
if (get_post_type() != 'post') {
$post_type = get_post_type_object(get_post_type());
$slug = $post_type->rewrite;
echo '
' . '' . $post_type->labels->singular_name . '' . '';
echo ' ' . $delimiter . ' ' . get_the_title();
}
else {
$category = get_the_category();
if ($category) {
foreach ($category as $cat) {
echo '
' . '' . $cat->name . '' . '' . $delimiter . ' ';
}
}
echo get_the_title();
}
}
elseif (!is_single() && !is_page() && get_post_type() != 'post' && !is_404()) {
$post_type = get_post_type_object(get_post_type());
echo $post_type->labels->singular_name;
}
elseif (is_attachment()) {
$parent = get_post($post->post_parent);
$cat = get_the_category($parent->ID);
$cat = $cat[0];
echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
echo '
' . '' . $parent->post_title . '' . '';
echo ' ' . $delimiter . ' ' . get_the_title();
}
elseif (is_page() && !$post->post_parent) {
$get_post_slug = $post->post_name;
$post_slug = str_replace('-', ' ', $get_post_slug);
echo '
' . '' . ucfirst($post_slug) . '' . '';
}
elseif (is_page() && $post->post_parent) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '
' . '' . get_the_title($page->ID) . '' . '';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
for ($i = 0; $i < count($breadcrumbs); $i++) {
echo $breadcrumbs[$i];
if ($i != count($breadcrumbs) - 1)
echo ' ' . $delimiter . ' ';
}
echo $delimiter . '
' . '' . the_title_attribute('echo=0') . '' . '';
}
elseif (is_tag()) {
$tag_id = get_term_by('name', single_cat_title('', false), 'post_tag');
if ($tag_id) {
$tag_link = get_tag_link($tag_id->term_id);
}
echo '
' . '' . single_cat_title('', false) . '' . '';
}
elseif (is_author()) {
global $author;
$userdata = get_userdata($author);
echo '
' . '' . $userdata->display_name . '' . '';
}
elseif (is_404()) {
echo 'Error 404';
}
elseif (is_search()) {
echo 'Search results for "' . get_search_query() . '"';
}
elseif (is_day()) {
echo '
' . '' . get_the_time('Y') . '' . '' . $delimiter . ' ';
echo '
' . '' . get_the_time('F') . '' . '' . $delimiter . ' ';
echo '
' . '' . get_the_time('d') . '' . '';
}
elseif (is_month()) {
echo '
' . '' . get_the_time('Y') . '' . '' . $delimiter . ' ';
echo '
' . '' . get_the_time('F') . '' . '';
}
elseif (is_year()) {
echo '
' . '' . get_the_time('Y') . '' . '';
}
if (get_query_var('paged')) {
if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author())
echo ' (';
echo __('Page') . ' ' . get_query_var('paged');
if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author())
echo ')';
}
echo '
';
}
}
Comments
Post a Comment