Guest User

Untitled

a guest
Jan 30th, 2011
1,285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. if (!function_exists('wwp_posttype_breadcrumb')){
  2. function wwp_posttype_breadcrumb( $args = '',$seperator = ">"){
  3. if (is_single()): // displays breadcrumb for single page - based off of wp_list_categories
  4. $defaults = array(
  5. 'show_option_all' => '', 'show_option_none' => __('No categories'),
  6. 'orderby' => 'name', 'order' => 'ASC',
  7. 'show_last_update' => 0, 'style' => 'list',
  8. 'show_count' => 0, 'hide_empty' => 1,
  9. 'use_desc_for_title' => 1, 'child_of' => 0,
  10. 'feed' => '', 'feed_type' => '',
  11. 'feed_image' => '', 'exclude' => '',
  12. 'exclude_tree' => '', 'current_category' => 0,
  13. 'hierarchical' => true, 'title_li' => __( 'Categories' ),
  14. 'echo' => 1, 'depth' => 0,
  15. 'taxonomy' => 'category'
  16. );
  17.  
  18. $r = wp_parse_args( $args, $defaults );
  19.  
  20. if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] )
  21. $r['pad_counts'] = true;
  22.  
  23. if ( isset( $r['show_date'] ) )
  24. $r['include_last_update_time'] = $r['show_date'];
  25.  
  26. if ( true == $r['hierarchical'] ) {
  27. $r['exclude_tree'] = $r['exclude'];
  28. $r['exclude'] = '';
  29. }
  30.  
  31. if ( !isset( $r['class'] ) )
  32. $r['class'] = ( 'category' == $r['taxonomy'] ) ? 'categories' : $r['taxonomy'];
  33.  
  34. extract( $r );
  35.  
  36. if ( !taxonomy_exists($taxonomy) )
  37. return false;
  38.  
  39. $categories = get_categories( $r );
  40.  
  41. $output = '';
  42. if ( $title_li && 'list' == $style )
  43. $output = '<li class="' . $class . '">' . $title_li . '<ul>';
  44.  
  45. if ( empty( $categories ) ) {
  46. if ( ! empty( $show_option_none ) ) {
  47. if ( 'list' == $style )
  48. $output .= '<li>' . $show_option_none . '</li>';
  49. else
  50. $output .= $show_option_none;
  51. }
  52. } else {
  53. global $wp_query;
  54.  
  55. if( !empty( $show_option_all ) )
  56. if ( 'list' == $style )
  57. $output .= '<li><a href="' . get_bloginfo( 'url' ) . '">' . $show_option_all . '</a></li>';
  58. else
  59. $output .= '<a href="' . get_bloginfo( 'url' ) . '">' . $show_option_all . '</a>';
  60.  
  61. if ( empty( $r['current_category'] ) && ( is_category() || is_tax() ) )
  62. $r['current_category'] = $wp_query->get_queried_object_id();
  63.  
  64. if ( $hierarchical )
  65. $depth = $r['depth'];
  66. else
  67. $depth = -1; // Flat.
  68.  
  69. $output .= walk_category_tree( $categories, $depth, $r );
  70. }
  71.  
  72. if ( $title_li && 'list' == $style )
  73. $output .= '</ul></li>';
  74.  
  75. $output = apply_filters( 'wp_list_categories', $output, $args );
  76. $output = explode( '<br />', $output ); // strip <br/>
  77. array_pop($output); // removes last element as its empty (nothing after the last <br/> tag)
  78. $output = implode(" ".$seperator." ",$output); // adds your seperator
  79. echo $output."<br/><br/>";
  80.  
  81. else: // this gets the heirachial taxonomies on taxonomy archive pages
  82. $term = get_term($GLOBALS['wp_query']->get_queried_object_id(), get_query_var('taxonomy'));
  83. $term_name = $term->name;
  84. $term_parent = $term->parent;
  85. while($term_parent){
  86. $term = get_term($term_parent, get_query_var('taxonomy'));
  87. $term_parent = $term->parent;
  88. //echo $term->name;
  89. $term_parents[] = array('name'=>$term->name, 'url'=>get_term_link((int)$term->term_id, get_query_var('taxonomy')));
  90. }
  91. if(!empty($term_parents)){
  92. $term_parents = array_reverse($term_parents);
  93. foreach($term_parents as $term){
  94. $output[] = '<a href="'.$term['url'].'">'.$term['name'].'</a>';
  95. };
  96. }
  97.  
  98. if (!empty($output)):
  99. $output = join( " ".$seperator." ", $output );
  100. endif;
  101. echo $output."<br/><br/>";
  102. endif;
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment