- if (!function_exists('wwp_posttype_breadcrumb')){
- function wwp_posttype_breadcrumb( $args = '',$seperator = ">"){
- if (is_single()): // displays breadcrumb for single page - based off of wp_list_categories
- $defaults = array(
- 'show_option_all' => '', 'show_option_none' => __('No categories'),
- 'orderby' => 'name', 'order' => 'ASC',
- 'show_last_update' => 0, 'style' => 'list',
- 'show_count' => 0, 'hide_empty' => 1,
- 'use_desc_for_title' => 1, 'child_of' => 0,
- 'feed' => '', 'feed_type' => '',
- 'feed_image' => '', 'exclude' => '',
- 'exclude_tree' => '', 'current_category' => 0,
- 'hierarchical' => true, 'title_li' => __( 'Categories' ),
- 'echo' => 1, 'depth' => 0,
- 'taxonomy' => 'category'
- );
- $r = wp_parse_args( $args, $defaults );
- if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] )
- $r['pad_counts'] = true;
- if ( isset( $r['show_date'] ) )
- $r['include_last_update_time'] = $r['show_date'];
- if ( true == $r['hierarchical'] ) {
- $r['exclude_tree'] = $r['exclude'];
- $r['exclude'] = '';
- }
- if ( !isset( $r['class'] ) )
- $r['class'] = ( 'category' == $r['taxonomy'] ) ? 'categories' : $r['taxonomy'];
- extract( $r );
- if ( !taxonomy_exists($taxonomy) )
- return false;
- $categories = get_categories( $r );
- $output = '';
- if ( $title_li && 'list' == $style )
- $output = '<li class="' . $class . '">' . $title_li . '<ul>';
- if ( empty( $categories ) ) {
- if ( ! empty( $show_option_none ) ) {
- if ( 'list' == $style )
- $output .= '<li>' . $show_option_none . '</li>';
- else
- $output .= $show_option_none;
- }
- } else {
- global $wp_query;
- if( !empty( $show_option_all ) )
- if ( 'list' == $style )
- $output .= '<li><a href="' . get_bloginfo( 'url' ) . '">' . $show_option_all . '</a></li>';
- else
- $output .= '<a href="' . get_bloginfo( 'url' ) . '">' . $show_option_all . '</a>';
- if ( empty( $r['current_category'] ) && ( is_category() || is_tax() ) )
- $r['current_category'] = $wp_query->get_queried_object_id();
- if ( $hierarchical )
- $depth = $r['depth'];
- else
- $depth = -1; // Flat.
- $output .= walk_category_tree( $categories, $depth, $r );
- }
- if ( $title_li && 'list' == $style )
- $output .= '</ul></li>';
- $output = apply_filters( 'wp_list_categories', $output, $args );
- $output = explode( '<br />', $output ); // strip <br/>
- array_pop($output); // removes last element as its empty (nothing after the last <br/> tag)
- $output = implode(" ".$seperator." ",$output); // adds your seperator
- echo $output."<br/><br/>";
- else: // this gets the heirachial taxonomies on taxonomy archive pages
- $term = get_term($GLOBALS['wp_query']->get_queried_object_id(), get_query_var('taxonomy'));
- $term_name = $term->name;
- $term_parent = $term->parent;
- while($term_parent){
- $term = get_term($term_parent, get_query_var('taxonomy'));
- $term_parent = $term->parent;
- //echo $term->name;
- $term_parents[] = array('name'=>$term->name, 'url'=>get_term_link((int)$term->term_id, get_query_var('taxonomy')));
- }
- if(!empty($term_parents)){
- $term_parents = array_reverse($term_parents);
- foreach($term_parents as $term){
- $output[] = '<a href="'.$term['url'].'">'.$term['name'].'</a>';
- };
- }
- if (!empty($output)):
- $output = join( " ".$seperator." ", $output );
- endif;
- echo $output."<br/><br/>";
- endif;
- }
- }