Last active
July 28, 2020 13:31
-
-
Save tamarazuk/63f3c62226aa4319cc3e to your computer and use it in GitHub Desktop.
WooCommerce Nested Category Layout - Remove parent category name from category title
This file contains hidden or 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
<?php | |
add_filter( 'wc_nested_category_layout_category_title_html', 'wc_nested_category_layout_category_title_html', 10, 3 ); | |
function wc_nested_category_layout_category_title_html( $title, $categories, $term ) { | |
$category = $categories[ count( $categories ) - 1 ]; | |
$url = esc_attr( get_term_link( $category ) ); | |
$link = '<a href="' . $url . '">' . wptexturize( $category->name ) . '</a>'; | |
return sprintf( '<h2 class="wc-nested-category-layout-category-title">%s</h2>', $link ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment