将主类别标题隐藏在唯一的类别存档页面上 [英] Hiding main category title on a unique category archive page

查看:61
本文介绍了将主类别标题隐藏在唯一的类别存档页面上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个具有许多不同类别的网站,只需要删除一个存档页面上的类别标题即可:

I'm building a site with many different categories and need to simply remove the category titles on just one archive page:

< a href = http://redyearclients.co.uk/PandF/product-category/exterior-paving/paving-brands/ rel = nofollow> 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/

推荐答案

为此,您将需要使用 woocommerce_page_title 过滤器挂钩和WooCommerce条件 is_product_category('category' )

For that purpose you will need to use woocommerce_page_title filter hook and the WooCommerce conditional is_product_category( 'category' ) together.

这里是代码:

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

此代码位于您的活动子主题(或主题)的function.php文件中,或

此代码已经过测试并且功能齐全。

This code is tested and fully functional.

参考: WooCommerce条件标签-产品类别页面

这篇关于将主类别标题隐藏在唯一的类别存档页面上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆