Wordpress : Breadcrumbs without plugin


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Functions.php:
  2.  
  3. function the_breadcrumb() {
  4. echo '<ul id="crumbs">';
  5. if (!is_home()) {
  6. echo '<li><a href="';
  7. echo get_option('home');
  8. echo '">';
  9. echo 'Home';
  10. echo "</a></li>";
  11. if (is_category() || is_single()) {
  12. echo '<li>';
  13. the_category(' </li><li> ');
  14. if (is_single()) {
  15. echo "</li><li>";
  16. the_title();
  17. echo '</li>';
  18. }
  19. } elseif (is_page()) {
  20. echo '<li>';
  21. echo the_title();
  22. echo '</li>';
  23. }
  24. }
  25. elseif (is_tag()) {single_tag_title();}
  26. elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
  27. elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
  28. elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
  29. elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
  30. elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
  31. elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
  32. echo '</ul>';
  33. }
  34.  
  35. Header.php:
  36.  
  37. <?php the_breadcrumb(); ?>

URL: http://wp-snippets.com/breadcrumbs-without-plugin/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.