Last active
October 30, 2018 14:40
-
-
Save nfsarmento/a5069880f8c09c28986b5a12cb32ad72 to your computer and use it in GitHub Desktop.
WordPress breadcrumbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generate breadcrumbs | |
* | |
* https://www.nuno-sarmento.com | |
*/ | |
function get_breadcrumb() { | |
echo '<a href="'.home_url().'" rel="nofollow">Home</a>'; | |
if (is_category() || is_single()) { | |
echo " » "; | |
the_category(' • '); | |
if (is_single()) { | |
echo " » "; | |
the_title(); | |
} | |
} elseif (is_page()) { | |
echo " » "; | |
echo the_title(); | |
} elseif (is_search()) { | |
echo " » Search Results for... "; | |
echo '"<em>'; | |
echo the_search_query(); | |
echo '</em>"'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.breadcrumb { | |
padding: 8px 15px; | |
margin-bottom: 20px; | |
list-style: none; | |
background-color: #f5f5f5; | |
border-radius: 4px; | |
} | |
.breadcrumb a { | |
color: #428bca; | |
text-decoration: none; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment