weblizar_breadcrumbs

Breadcrumbs.

Description

weblizar_breadcrumbs(); 

Usage

  1. if ( !function_exists( 'weblizar_breadcrumbs' ) ) { 
  2. require_once '/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = weblizar_breadcrumbs(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/functions.php  
  1. function weblizar_breadcrumbs() { 
  2. $delimiter = ''; 
  3. $home = __('Home', 'enigma' ); // text for the 'Home' link 
  4. $before = '<li>'; // tag before the current crumb 
  5. $after = '</li>'; // tag after the current crumb 
  6. echo '<ul class="breadcrumb">'; 
  7. global $post; 
  8. $homeLink = home_url(); 
  9. echo '<li><a href="' . $homeLink . '">' . $home . '</a></li>' . $delimiter . ' '; 
  10. if (is_category()) { 
  11. global $wp_query; 
  12. $cat_obj = $wp_query->get_queried_object(); 
  13. $thisCat = $cat_obj->term_id; 
  14. $thisCat = get_category($thisCat); 
  15. $parentCat = get_category($thisCat->parent); 
  16. if ($thisCat->parent != 0) 
  17. echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' ')); 
  18. echo $before . ' _e("Archive by category", "enigma") "' . single_cat_title('', false) . '"' . $after; 
  19. } elseif (is_day()) { 
  20. echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a></li> ' . $delimiter . ' '; 
  21. echo '<li><a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a></li> ' . $delimiter . ' '; 
  22. echo $before . get_the_time('d') . $after; 
  23. } elseif (is_month()) { 
  24. echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a></li> ' . $delimiter . ' '; 
  25. echo $before . get_the_time('F') . $after; 
  26. } elseif (is_year()) { 
  27. echo $before . get_the_time('Y') . $after; 
  28. } elseif (is_single() && !is_attachment()) { 
  29. if (get_post_type() != 'post') { 
  30. $post_type = get_post_type_object(get_post_type()); 
  31. $slug = $post_type->rewrite; 
  32. echo '<li><a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a></li> ' . $delimiter . ' '; 
  33. echo $before . get_the_title() . $after; 
  34. } else { 
  35. $cat = get_the_category(); 
  36. $cat = $cat[0]; 
  37. //echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); 
  38. echo $before . get_the_title() . $after; 
  39.  
  40. } elseif (!is_single() && !is_page() && get_post_type() != 'post') { 
  41. $post_type = get_post_type_object(get_post_type()); 
  42. echo $before . $post_type->labels->singular_name . $after; 
  43. } elseif (is_attachment()) { 
  44. $parent = get_post($post->post_parent); 
  45. $cat = get_the_category($parent->ID); 
  46. //$cat = $cat[0]; 
  47. // echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); 
  48. echo '<li><a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a></li> ' . $delimiter . ' '; 
  49. echo $before . get_the_title() . $after; 
  50. } elseif (is_page() && !$post->post_parent) { 
  51. echo $before . get_the_title() . $after; 
  52. } elseif (is_page() && $post->post_parent) { 
  53. $parent_id = $post->post_parent; 
  54. $breadcrumbs = array(); 
  55. while ($parent_id) { 
  56. $page = get_page($parent_id); 
  57. $breadcrumbs[] = '<li><a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a></li>'; 
  58. $parent_id = $page->post_parent; 
  59. $breadcrumbs = array_reverse($breadcrumbs); 
  60. foreach ($breadcrumbs as $crumb) 
  61. echo $crumb . ' ' . $delimiter . ' '; 
  62. echo $before . get_the_title() . $after; 
  63. } elseif (is_search()) { 
  64. echo $before . _e("Search results for", "enigma") . get_search_query() . '"' . $after; 
  65.  
  66. } elseif (is_tag()) {  
  67. echo $before . _e('Tag', 'enigma') . single_tag_title('', false) . $after; 
  68. } elseif (is_author()) { 
  69. global $author; 
  70. $userdata = get_userdata($author); 
  71. echo $before . _e("Articles posted by", "enigma") . $userdata->display_name . $after; 
  72. } elseif (is_404()) { 
  73. echo $before . _e("Error 404", "enigma") . $after; 
  74.  
  75. echo '</ul>';