Skip to content

Instantly share code, notes, and snippets.

@panagiotisTB
Created July 7, 2016 09:57
Show Gist options
  • Save panagiotisTB/e17aed7a87cfb0ba0e165860a561c330 to your computer and use it in GitHub Desktop.
Save panagiotisTB/e17aed7a87cfb0ba0e165860a561c330 to your computer and use it in GitHub Desktop.
a custom breadcrumb function for wordpress
<?php
function the_breadcrumb()
{
global $post;
$returnHTMLString = '';
$postTitle = strtoupper(get_the_title());
$space = str_repeat('&nbsp;', 3);
$parent_title = strtoupper(get_the_title($post->post_parent));
$parent_title = str_replace(" ▾","" , $parent_title);
if (!is_home()) {
$returnHTMLString .= '<a href="';
$returnHTMLString .= get_option('home');
$returnHTMLString .= '">';
$returnHTMLString .= "HOME";
$returnHTMLString .= "</a><span>" . $space . " ▹ " . $space;
if (is_category() || is_single() || is_page()) {
if ($postTitle != $parent_title) {
$returnHTMLString .= $parent_title . $space . " ▹ " . $space;
$returnHTMLString .= $postTitle . "</span>";
} else {
$returnHTMLString .= $postTitle . "</span>";
}
}
}
return $returnHTMLString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment