问题
On some Woocommerce category pages I would like to change the default Category Page title to something custom. I dont want to change the original "name" on the backend.
Is there some code that I can use for this in functions.php?
回答1:
The following will allow you to customize the page title on Woocommerce product category pages, for specific product categories:
add_filter( 'woocommerce_page_title', 'customize_woocommerce_page_title', 10, 1 );
function customize_woocommerce_page_title( $page_title) {
// Custom title for the product category 't-shirts'
if ( is_product_category('t-shirts') ) {
$page_title = 'Something';
}
// Custom title for the product category 'hoodies'
elseif ( is_product_category('hoodies') ) {
$page_title = 'Something else';
}
return $page_title;
}
Code goes in function.php file of your active child theme (or active theme). Tested and work.
来源:https://stackoverflow.com/questions/53874451/custom-category-page-title-in-woocommerce