我正在尝试使用 Uncode 主题显示 WooCommerce 类别描述。有谁知道我该怎么做?

问题描述 投票:0回答:1

下面是我找到的代码 - 我不确定这是否是我应该编辑的:

if ($show_title) {
    if ( apply_filters( 'uncode_use_description_in_product_tax_archives', false) ) {
        $get_title = get_queried_object()->description !== '' ? get_queried_object()->description : woocommerce_page_title(false);
    } else {
        $tax = get_taxonomy( get_queried_object()->taxonomy );
        $get_title = single_term_title( '', false); }

    
    $title_content = '<div class="post-title-wrapper"><h1 class="post-title">' . $get_title . '</h1></div>';
}

我尝试了一些不同的插件来尝试添加代码片段。我尝试了一些代码,这些代码可以工作并显示描述,但是编辑 CSS 变得相当困难

php woocommerce categories
1个回答
0
投票

在您提供的问题代码中,

uncode_use_description_in_product_tax_archives
过滤器挂钩默认设置为
false

您无需编辑代码即可显示产品类别描述。

相反,请在子主题(或插件)的functions.php 文件中添加以下内容:

add_filter( 'uncode_use_description_in_product_tax_archives', '__return_true');

现在应该显示产品类别描述。

© www.soinside.com 2019 - 2024. All rights reserved.