问题
I'm building a site with many different categories and need to simply remove the category titles on just one archive page:
http://redyearclients.co.uk/PandF/product-category/exterior-paving/paving-brands/
I've discovered methods of removing the title from all pages, but I need all other category pages to require the title, this page for example should stay as it looks now:
http://redyearclients.co.uk/PandF/product-category/exterior-paving/
Any help massively appreciated.
回答1:
For that purpose you will need to use woocommerce_page_title
filter hook and the WooCommerce conditional is_product_category( 'category' )
together.
Here is that code:
function removing_specific_category_page_title( $page_title ) {
// Define HERE below your category slug to hide the corresponding title
$category = 'my_category';
if(is_product_category($category))
$page_title = '';
return $page_title;
}
add_filter( 'woocommerce_page_title', 'removing_specific_category_page_title', 10, 1 );
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
This code is tested and fully functional.
Reference: WooCommerce Conditional Tags - Product Category Pages
来源:https://stackoverflow.com/questions/39768430/hiding-main-category-title-on-a-unique-category-archive-page