From 2c4c9182d7fa9eae1e6337dd82cd5e949f76abe4 Mon Sep 17 00:00:00 2001 From: Allyson Alves de Souza Date: Thu, 31 Mar 2016 18:40:32 -0300 Subject: [PATCH] =?UTF-8?q?Ajuste=20de=20atribui=C3=A7=C3=A3o=20de=20taxon?= =?UTF-8?q?omia=20para=20produtos=20do=20Woocommerce=20nas=20breadcrumbs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/helpers.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/core/helpers.php b/core/helpers.php index fcad209..67d5f7d 100644 --- a/core/helpers.php +++ b/core/helpers.php @@ -254,25 +254,27 @@ function odin_breadcrumbs( $homepage = '' ) { } // Gets post type taxonomies. - $taxonomy = get_object_taxonomies( 'product' ); - $taxy = 'product_cat'; - + $taxonomies = get_object_taxonomies( 'product' ); + $taxonomy = 'product_cat'; } else { $post_type = get_post_type_object( $post->post_type ); echo '
  • ' . $post_type->label . '
  • '; // Gets post type taxonomies. - $taxonomy = get_object_taxonomies( $post_type->name ); + $taxonomies = get_object_taxonomies( $post_type->name ); } - if ( $taxonomy ) { - $taxy = $taxonomy[0]; + if ( $taxonomies ) { + // If is woocommerce product post type, $taxonomy already defined + if ( 'product' !== $post->post_type ) { + $taxonomy = $taxonomies[0]; + } // Gets post terms. - $terms = get_the_terms( $post->ID, $taxy ); + $terms = get_the_terms( $post->ID, $taxonomy ); $term = $terms ? array_shift( $terms ) : ''; // Gets parent post terms. - $parent_term = get_term( $term->parent, $taxy ); + $parent_term = get_term( $term->parent, $taxonomy ); if ( $term ) { if ( $term->parent ) {