diff --git a/inc/extras.php b/inc/extras.php index 0541d2a..a43e8f2 100644 --- a/inc/extras.php +++ b/inc/extras.php @@ -218,14 +218,18 @@ function flash_breadcrumbs() { $slice_array = array_slice( $category, -1 ); $last_category = array_pop( $slice_array ); - // Get parent any categories and create array - $get_cat_parents = rtrim( get_category_parents( $last_category->term_id, true, ',' ), ',' ); - $cat_parents = explode( ',', $get_cat_parents ); + // Get parent categories and the category itself, top-most ancestor first. + $cat_ancestors = array_reverse( get_ancestors( $last_category->term_id, 'category' ) ); + $cat_ancestors[] = $last_category->term_id; // Loop through parent categories and store in variable $cat_display $cat_display = ''; - foreach ( $cat_parents as $parents ) { - $cat_display .= '
  • ' . $parents . '
  • '; + foreach ( $cat_ancestors as $cat_id ) { + $cat_term = get_term( $cat_id, 'category' ); + + if ( $cat_term && ! is_wp_error( $cat_term ) ) { + $cat_display .= '
  • ' . esc_html( $cat_term->name ) . '
  • '; + } } } @@ -294,28 +298,28 @@ function flash_breadcrumbs() { // Day archive // Year link - echo '
  • ' . esc_html( get_the_time( __( 'Y', 'flash' ) ) ) . '
  • '; + echo '
  • ' . esc_html( get_the_time( 'Y' ) ) . '
  • '; // Month link - echo '
  • ' . esc_html( get_the_time( __( 'M', 'flash' ) ) ) . '
  • '; + echo '
  • ' . esc_html( get_the_time( 'M' ) ) . '
  • '; // Day display - echo '
  • ' . esc_html( get_the_time( __( 'jS', 'flash' ) ) . get_the_time( __( 'M', 'flash' ) ) ) . '
  • '; + echo '
  • ' . esc_html( get_the_time( 'jS' ) . ' ' . get_the_time( 'M' ) ) . '
  • '; } elseif ( is_month() ) { // Month Archive // Year link - echo '
  • ' . esc_html( get_the_time( __( 'Y', 'flash' ) ) ) . '
  • '; + echo '
  • ' . esc_html( get_the_time( 'Y' ) ) . '
  • '; // Month link - echo '
  • ' . esc_html( get_the_time( __( 'M', 'flash' ) ) ) . '
  • '; + echo '
  • ' . esc_html( get_the_time( 'M' ) ) . '
  • '; } elseif ( is_year() ) { // Display year archive - echo '
  • ' . esc_html( get_the_time( __( 'Y', 'flash' ) ) ) . '
  • '; + echo '
  • ' . esc_html( get_the_time( 'Y' ) ) . '
  • '; } elseif ( is_author() ) { @@ -326,7 +330,9 @@ function flash_breadcrumbs() { $userdata = get_userdata( $author ); // Display author name - echo '
  • ' . esc_html( $userdata->display_name ) . '
  • '; + if ( $userdata ) { + echo '
  • ' . esc_html( $userdata->display_name ) . '
  • '; + } } elseif ( get_query_var( 'paged' ) ) {