Created
May 27, 2019 13:14
-
-
Save felipe-pita/603ffe5e5b4b8d31e0ebffea3ffaa60c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Breadcrumb na single de produto | |
*/ | |
add_action( 'woocommerce_single_product_summary', 'single_product_breadcrumb', 0 ); | |
function single_product_breadcrumb() { | |
global $post; | |
$out = '<div class="breadcrumbs">'; | |
$out .= '<div class="breadcrumbs__container container">'; | |
$out .= '<a href="' . get_site_url() . '">Home</a> » '; | |
$term_list = wp_get_post_terms($post->ID, 'product_cat', ['fields' => 'all', 'parent' => 0]); | |
$primary_term = $term_list[0]; | |
if (isset($primary_term)) { | |
$out .= '<a href="' . get_term_link($primary_term, 'product_cat') . '">' . $primary_term->name . '</a>'; | |
} | |
$out .= '</div>'; | |
$out .= '</div>'; | |
echo $out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment