Need Help Setting Up Shortcode for Woocommerce Category Name

Hi All,

Just trying to show a product category name on a page using a custom shortcode. I’ve used the following in my child theme’s functions.php…

// Create Category title shortcode
// ==================================
 
function category_title_sc( ){
   return single_cat_title();
}
add_shortcode( 'category_title', 'category_title_sc' );

When I add the [category_title] shortcode to my WooCommerce custom template for category pages (I’m using the DHVC Woocommerce Products Layouts plugin with Visual Composer) and check the source code generated it is as follows…

"Used Tractors
	"

There is now HTML if I want to wrap an h2 around it for example.

Can anyone help?

Many thanks,
Adam

Hi,

Anyone able to assist?

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.