Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamarazuk/63f3c62226aa4319cc3e to your computer and use it in GitHub Desktop.
Save tamarazuk/63f3c62226aa4319cc3e to your computer and use it in GitHub Desktop.
WooCommerce Nested Category Layout - Remove parent category name from category title
<?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