clocallocy clace the It显示了单数中的分类法,但是当我在托管上安装WordPress时,该分类法在复数中显示,并在我想获得IT时会导致某些错误 localhost/myweb/wp-admin/edit-tags.php?galsonomy =

问题描述 投票:0回答:0
如果它是单数,我该如何将其更改为单数?

在WordPress中,WooCommerce会自动使自定义分类法的SLUG倍增。这就是为什么您在Live站点和本地product_brand(单数)上看到product_brands(复数)的原因。 WooCommerce使用默认情况下与产品相关的分类法使用复数sl。 如何确保一致性(单数或复数) WooCommerce的默认行为:默认情况下,WooCommerce使用诸如product_brands,product_categories等分类法的复数名称。 使用单数slug:如果您想制作分类法单数并避免复数形式,则需要修改分类法的注册。您可以通过挂接Init Action并用所需的slug进行注册。

function change_product_brand_taxonomy_slug() { unregister_taxonomy('product_brand'); register_taxonomy('product_brand', 'product', array( 'labels' => array( 'name' => 'Product Brands', 'singular_name' => 'Product Brand', ), 'rewrite' => array( 'slug' => 'product_brand', ), 'hierarchical' => true, )); } add_action('init', 'change_product_brand_taxonomy_slug');

php wordpress woocommerce custom-taxonomy taxonomy-terms
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.