Custom category page title in Woocommerce

安稳与你 提交于 2021-01-28 14:38:10

问题


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

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