title: I want to add "Category" to my WP breadcrumbs
body: <p>I have a premium WordPress theme which has breadcrumbs by default, but it does not show Category (and Sub-Category) item when on post page: <em>Home > Category > Sub-Category > Post Title</em></p>
  
  <p>Instead it just displays like this: <em>Home > Post Title</em></p>
  
  <p>This is the function which handles breadcrumbs:</p>
  
  <p>(I marked the part of the code that I think is important with this sign, to save you time: ==========>>)</p>
  
  <pre><code>// BREADCRUMBS
  if ( ! function_exists( 'ishyoboy_get_breadcrumbs' ) ) {
      function ishyoboy_get_breadcrumbs() {
  
          global $ish_options, $ish_woo_id;
  
          $return = '';
  
          $return .= '&lt;div class="ish-pb-breadcrumbs"&gt;&lt;div&gt;&lt;div&gt;' . "\n";
  
          if ( ! is_front_page() ) {
              if ( function_exists('is_woocommerce') ) {
                  if ( !is_woocommerce() &amp;&amp; !is_woocommerce_page() ){
                      $return .= '&lt;a class="ish-pb-breadcrumbs-home" href="';
                      $return .= home_url();
                      $return .= '"&gt;';
                      $return .= '&lt;span&gt;' . __( 'Home', 'ishyoboy' ) . '&lt;/span&gt;';
                      $return .= "&lt;/a&gt; &amp;gt; ";
                  }
  
              }
              else{
                  $return .= '&lt;a class="ish-pb-breadcrumbs-home" href="';
                  $return .= home_url();
                  $return .= '"&gt;';
                  $return .= '&lt;span&gt;' . __( 'Home', 'ishyoboy' ) . '&lt;/span&gt;';
                  $return .= "&lt;/a&gt; &amp;gt; ";
              }
  
          }
          else {
              $return .= '&lt;span class="ish-pb-breadcrumbs-home"&gt;';
              $return .= '&lt;span&gt;' . __( 'Home', 'ishyoboy' ) . '&lt;/span&gt;';
              $return .= "&lt;/span&gt;";
          }
  
          if ( !is_front_page() &amp;&amp; is_home() ) {
              global $page;
              $return .= $page-&gt;post_title;
          }
  
          if ( is_archive() &amp;&amp; 'post' == get_post_type() &amp;&amp; ! is_category() &amp;&amp; ( !function_exists('is_woocommerce') || !is_woocommerce() )  ) {
              $hpage = get_page( get_option( 'page_for_posts' ) );
              if ( 'page' == get_option('show_on_front') &amp;&amp; isset($hpage) &amp;&amp; '' != $hpage ){
                  $return .=  get_page_parents($hpage-&gt;ID, TRUE, ' &amp;gt; ', FALSE );
              }
              if ( is_day() ) :
                  $return .= sprintf( __( 'Daily Archives: %s', 'ishyoboy' ), '&lt;span&gt;' . get_the_date() . '&lt;/span&gt;' );
              elseif ( is_month() ) :
                  $return .= sprintf( __( 'Monthly Archives: %s', 'ishyoboy' ), '&lt;span&gt;' . get_the_date( _x( 'F Y', 'monthly archives date format', 'ishyoboy' ) ) . '&lt;/span&gt;' );
              elseif ( is_year() ) :
                  $return .= sprintf( __( 'Yearly Archives: %s', 'ishyoboy' ), '&lt;span&gt;' . get_the_date( _x( 'Y', 'yearly archives date format', 'ishyoboy' ) ) . '&lt;/span&gt;' );
              else :
                  $return .= __( 'Archives', 'ishyoboy' );
              endif;
          }
          else if ( is_archive() &amp;&amp; 'post' != get_post_type() &amp;&amp; ( !function_exists('is_woocommerce') || !is_woocommerce() )  ) {
  
              $type = get_post_type( get_the_ID() );
  
              $obj = get_post_type_object( $type );
              if ( is_object( $obj ) ){
                  $return .= $obj-&gt;labels-&gt;name;
              }
  
          }
  
          if ( (is_category() || is_single()) &amp;&amp; ( ( !function_exists('is_woocommerce_page') || !function_exists('is_woocommerce' ) ) || ( !is_woocommerce() &amp;&amp; !is_woocommerce_page() ) ) ) {
  
              $post_id = ish_get_the_ID();
              $post_type = get_post_type();
  
              switch ($post_type){
                  case 'portfolio-post' :
                      $terms = get_the_terms($post_id, 'portfolio-category' );
                      $term = ( ! empty( $terms ) ) ? array_pop($terms) : '';
  
                      if (isset($ish_options['page_for_custom_post_type_portfolio-post']) &amp;&amp; '-1' != $ish_options['page_for_custom_post_type_portfolio-post']){
  
                          $portfolio_page = get_page($ish_options['page_for_custom_post_type_portfolio-post']);
                          $separator = " &amp;gt; ";
                          $return .= '&lt;a href="' . get_page_link( $ish_options['page_for_custom_post_type_portfolio-post'] ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" , 'ishyoboy' ), $portfolio_page-&gt;post_title ) ) . '"&gt;'.$portfolio_page-&gt;post_title.'&lt;/a&gt;' . $separator;
                      }
  
                      if ( ! empty( $term ) ){
                          $return .= get_term_parents($term-&gt;term_id, 'portfolio-category', TRUE, ' &amp;gt; ', FALSE );
                      }
                      break;
  
  // from here ==========&gt;&gt;
  
                  case 'post' :
  
                      if ( is_category() ){
                          global  $cat;
                          $category = get_category($cat);
                          if ( $category-&gt;parent &amp;&amp; ( $category-&gt;parent != $category-&gt;term_id ) ){
                              $return .= get_category_parents($category-&gt;parent, TRUE, ' &amp;gt; ', FALSE );
                          }
                          $return .= single_cat_title('', false);
                      }
                      else{
                          $category = get_the_category();
                          if ( is_object( $category ) ){
                              $ID = $category[0]-&gt;cat_ID;
                              $return .= get_category_parents($ID, TRUE, ' &amp;gt; ', FALSE );
                          }
                      }
                      break;
  
  // to here ==========&gt;&gt;
  
                  default :
                      $type = get_post_type( get_the_ID() );
  
                      $obj = get_post_type_object( $type );
                      if ( is_object( $obj ) ){
                          $return .= '&lt;a href="' . get_post_type_archive_link( $type ) .'"&gt;' . $obj-&gt;labels-&gt;name . '&lt;/a&gt; &amp;gt; ';
                      }
  
              }
          }
          else if ( ( function_exists('is_woocommerce_page') &amp;&amp; function_exists('is_woocommerce') ) &amp;&amp; (is_woocommerce() || is_woocommerce_page() )){
              ob_start();
              woocommerce_breadcrumb(array(
                  'delimiter'   =&gt; ' &amp;gt; ',
                  'wrap_before' =&gt; '',
                  'wrap_after'  =&gt; '',
                  'before'      =&gt; '',
                  'after'       =&gt; '',
                  'home'        =&gt; '&lt;span class="ish-pb-breadcrumbs-home"&gt;&lt;span&gt;' . _x( 'Home', 'breadcrumb', 'woocommerce' ) . '&lt;/span&gt;&lt;/span&gt;',
              ));
              $return .= ob_get_contents();
              ob_end_clean();
              ob_end_flush();
          }
          else if (is_tax()){
              if (is_tax('portfolio-category')){
  
                  $current_term = get_queried_object();
  
                  if ( !empty($current_term) ){
                      //var_dump($current_term);
  
                      if (isset($ish_options['page_for_custom_post_type_portfolio-post']) &amp;&amp; '-1' != $ish_options['page_for_custom_post_type_portfolio-post']){
  
                          $portfolio_page = get_page($ish_options['page_for_custom_post_type_portfolio-post']);
                          $separator = " &amp;gt; ";
                          $return .= '&lt;a href="' . get_page_link( $ish_options['page_for_custom_post_type_portfolio-post'] ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" , 'ishyoboy' ), $portfolio_page-&gt;post_title ) ) . '"&gt;'.$portfolio_page-&gt;post_title.'&lt;/a&gt;' . $separator;
                      }
  
                      if ($current_term-&gt;parent != 0 ){
                          $return .= get_term_parents($current_term-&gt;parent, 'portfolio-category', TRUE, ' &amp;gt; ', FALSE );
                      }
  
                      $return .= $current_term-&gt;name;
                  }
              }
          }
          else if (is_page()){
              global $post;
  
              if ($post-&gt;post_parent != 0 ){
                  $return .= get_page_parents($post-&gt;post_parent, TRUE, ' &amp;gt; ', FALSE );
              }
          }
  
          if (!function_exists('is_woocommerce_page') || !is_woocommerce_page()){
              if(is_single()) {$return .= get_the_title();}
              if(is_page()) {
                  global $post;
                  $frontpage = get_option('page_on_front');
  
                  if ( $frontpage &amp;&amp; $frontpage == $post-&gt;ID){
                      /*$return .= '&lt;a class="home" href="';
                      $return .= home_url();
                      $return .= '"&gt;';
                      $return .= '&lt;span&gt;' . __( 'Home', 'ishyoboy' ) . '&lt;/span&gt;';
                      $return .= "&lt;/a&gt;";*/
                  } else {
                      $return .= get_the_title();
                  }
              }
              if(is_tag()){ $return .= __( 'Tag: ', 'ishyoboy' ) . single_tag_title('',FALSE); }
              if(is_404()){ $return .= __( '404 - Page not Found', 'ishyoboy' ); }
              if(is_search()){ $return .= __( 'Search', 'ishyoboy' ); }
              if(is_year()){ $return .= get_the_time('Y'); };
          }
  
          $return .= '&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;';
  
          return $return;
      }
  }
  
  if ( !function_exists('the_post_thumbnail_caption') ) {
      function the_post_thumbnail_caption(){
  
          $thumb = get_post_thumbnail_id();
  
          if ( ! empty( $thumb ) ){
              $thumb_object = get_post( $thumb );
              if ( ! empty( $thumb_object ) ) {
                  echo '&lt;div class="wp-caption"&gt;&lt;p class="wp-caption-text"&gt;' . $thumb_object-&gt;post_excerpt . '&lt;/p&gt;&lt;/div&gt;';
              }
          }
  
      }
  }
  
  if ( !function_exists('get_the_post_thumbnail_caption') ) {
      function get_the_post_thumbnail_caption(){
  
          $thumb = get_post_thumbnail_id();
  
          if ( ! empty( $thumb ) )
              return get_post( $thumb )-&gt;post_excerpt;
  
          return null;
      }
  }
  
  if ( ! function_exists( 'ishyoboy_activate_fancybox_on_blog_single' ) ) {
      function ishyoboy_activate_fancybox_on_blog_single() {
  
          if ( is_singular() &amp;&amp; !is_singular( 'product' ) ){
              ?&gt;
              &lt;script type="text/javascript"&gt;
                  jQuery(document).ready(function($){
                      var thumbnails = jQuery("a:has(img)").not(".nolightbox").filter( function() { return /\.(jpe?g|png|gif|bmp)$/i.test(jQuery(this).attr('href')) });
  
                      if ( thumbnails.length &gt; 0){
                          thumbnails.addClass( 'openfancybox-image' ).attr( 'rel', 'fancybox-post-image-&lt;?php the_ID() ?&gt;');
                      }
                  });
              &lt;/script&gt;
          &lt;?php
          }
  
      }
  }
  add_action( 'wp_head', 'ishyoboy_activate_fancybox_on_blog_single' );
  
  
  if ( ! function_exists( 'ishyoboy_dummy_functions' ) ) {
      function ishyoboy_dummy_functions() {
  
          if ( false ) {
              posts_nav_link();
              wp_link_pages();
              $args = '';
              add_theme_support( 'custom-header', $args );
              add_theme_support( 'custom-background', $args );
          }
  
      }
  }
  </code></pre>
  
  <p>And then I've made a change in code which generated the desired change - Category appeared in breadcrumbs: <em>Home > Category > Sub-Category > Post Title</em></p>
  
  <p>But on the Category archive page breadcrumbs look like this: <em>Home > Category > Category</em></p>
  
  <p>Live example: <a href="http://pigtelligent.com/science/" rel="nofollow">http://pigtelligent.com/science/</a></p>
  
  <p>The change I've made in above-mentioned code:</p>
  
  <pre><code>        case 'post' :
              $terms = get_the_terms($post_id, 'category' );
              $term = ( ! empty( $terms ) ) ? array_pop($terms) : '';
              if ( ! empty( $term ) ){
                  $return .= get_term_parents($term-&gt;term_id, 'category', TRUE, ' &amp;gt; ', FALSE );
              }
  </code></pre>
  
  <p>I know that for someone smarter this should be easy, but I've spent whole day trying to figure this out, so can you please help me? :)</p>