Skip to content

Instantly share code, notes, and snippets.

@ewistrand
Created November 25, 2015 21:09
Show Gist options
  • Save ewistrand/46022a134a8f58e01834 to your computer and use it in GitHub Desktop.
Save ewistrand/46022a134a8f58e01834 to your computer and use it in GitHub Desktop.
Wordpress Breadcrumbs
function the_breadcrumb() {
global $post;
echo '<ul id="crumbs">';
if (!is_home()) {
echo '<li><a href="';
echo get_option('home');
echo '">';
echo 'Home';
echo "</a></li>";
if (is_category() || is_single()) {
echo '<li>';
the_category(' </li><li> ');
if (is_single()) {
echo "</li><li>";
the_title();
echo '</li>';
}
} elseif (is_page()) {
if($post->post_parent) {
$parent_post = get_post($post->post_parent);
if($parent_post->post_parent) {
echo '<li>' . get_the_title($parent_post->post_parent) . '</li>';
}
echo '<li>' . get_the_title($post->post_parent) . '</li>';
}
echo '<li>';
echo the_title();
echo '</li>';
}
}
elseif (is_tag()) {single_tag_title();}
elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
echo '</ul>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment