tamarazuk
11/19/2014 - 7:14 AM

WooCommerce Nested Category Layout - Remove parent category name from category title

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 );
}