Hiding main category title on a unique category archive page

依然范特西╮ 提交于 2019-12-23 15:54:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!