Add Breadcrumbs Without A Plugin In WordPress
Using breadcrumbs for page navigation is a great way to let your visitors know where they are and where they came from as they navigate your website; it gives them an idea of your site’s page hierarchy. Plus, did you know that it is also one way to optimize your site for search engines as well?
Here’s a pretty neat way of adding breadcrumbs to your WordPress site without using any plugin. Just copy and then paste the following code below into your functions.php file.
function the_breadcrumb() { 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()) { 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>'; }
And then copy and paste this one anywhere in your theme files to display the breadcrumbs.
<?php the_breadcrumb(); ?>
That’s it. You’re done!
4 Comments
search engine rankings
02.18.2013
It’s a shame you don’t have a donate button! I’d definitely donate to this outstanding blog! I guess for now i’ll settle
for book-marking and adding your RSS feed to my Google account.
I look forward to fresh updates and will talk
about this website with my Facebook group. Chat soon!
Google Ranking
02.18.2013
Very nice blog post. I absolutely love this site.
Keep writing!
Ross
02.20.2013
Hi there would you mind stating which blog platform you’re using? I’m planning to start my own blog soon but I’m having a difficult time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design and style seems different then most blogs and I’m looking for something completely unique.
P.S My apologies for being off-topic but I
had to ask!
Delbert
02.20.2013
Hey! Do you know if they make any plugins to assist with SEO?
I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good results.
If you know of any please share. Appreciate it!
There are no trackbacks to display at this time.