inkthemes_breadcrumbs

Breadcrumbs Plugin -----------------------------------------------------------------------------------.

Description

inkthemes_breadcrumbs(); 

Usage

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

Defined (1)

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

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