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. $delimiter = '»'; 
  3. $home = 'Home'; // text for the 'Home' link 
  4. $before = '<span class="current">'; // tag before the current crumb 
  5. $after = '</span>'; // tag after the current crumb 
  6. echo '<div id="crumbs">'; 
  7. global $post; 
  8. $homeLink = home_url(); 
  9. echo '<a href="' . $homeLink . '">' . $home . '</a> ' . $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 . 'Archive by category "' . single_cat_title('', false) . '"' . $after; 
  19. elseif (is_day()) { 
  20. echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' '; 
  21. echo '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' '; 
  22. echo $before . get_the_time('d') . $after; 
  23. } elseif (is_month()) { 
  24. echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $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 '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a> ' . $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. } elseif (!is_single() && !is_page() && get_post_type() != 'post') { 
  40. $post_type = get_post_type_object(get_post_type()); 
  41. echo $before . $post_type->labels->singular_name . $after; 
  42. } elseif (is_attachment()) { 
  43. $parent = get_post($post->post_parent); 
  44. $cat = get_the_category($parent->ID); 
  45. $cat = $cat[0]; 
  46. echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); 
  47. echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a> ' . $delimiter . ' '; 
  48. echo $before . get_the_title() . $after; 
  49. } elseif (is_page() && !$post->post_parent) { 
  50. echo $before . get_the_title() . $after; 
  51. } elseif (is_page() && $post->post_parent) { 
  52. $parent_id = $post->post_parent; 
  53. $breadcrumbs = array(); 
  54. while ($parent_id) { 
  55. $page = get_page($parent_id); 
  56. $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>'; 
  57. $parent_id = $page->post_parent; 
  58. $breadcrumbs = array_reverse($breadcrumbs); 
  59. foreach ($breadcrumbs as $crumb) 
  60. echo $crumb . ' ' . $delimiter . ' '; 
  61. echo $before . get_the_title() . $after; 
  62. } elseif (is_search()) { 
  63. echo $before . 'Search results for "' . get_search_query() . '"' . $after; 
  64. } elseif (is_tag()) { 
  65. echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after; 
  66. } elseif (is_author()) { 
  67. global $author; 
  68. $userdata = get_userdata($author); 
  69. echo $before . 'Articles posted by ' . $userdata->display_name . $after; 
  70. } elseif (is_404()) { 
  71. echo $before . 'Error 404' . $after; 
  72. if (get_query_var('paged')) { 
  73. if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) 
  74. echo ' ('; 
  75. echo __('Page', 'road-fighter') . ' ' . get_query_var('paged'); 
  76. if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) 
  77. echo ')'; 
  78. echo '</div>';