加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > CMS系统 > wordpress > 正文

WooCommerce添加额外自定义参数

发布时间:2020-12-14 14:23:55 所属栏目:wordpress 来源:网络整理
导读:由站长 通过网络收集整理的代码片段。编程之家小编现在分享给大家,也给大家做个参考。 WooCommerce 是基于 wordpress 的购物网站最有力的插件被广泛使用。WooCommerce 本身是一款免费的插件,但它提供了丰富的扩展接口,为网站的进一步开发

以下代码由PHP站长网 52php.cn收集自互联网现在PHP站长网小编把它分享给大家,仅供参考

WooCommerce 是基于 wordpress 的购物网站最有力的插件被广泛使用。WooCommerce 本身是一款免费的插件,但它提供了丰富的扩展接口,为网站的进一步开发提供了无限的可能,WooCommerce 中的标签和 WordPress 中的文章标签几乎是一个道理,有些人会认为标签和分类十分接近,没有必要使用标签。默认提供了分类和标签字段,但是,有的时候我们需要更多自定义的字段,并且显示在商品页的其他位置,这就需要在 Woocommerce 插件的商品后台增加自定义字段。


实例代码:

register_taxonomy(

'product_jibie',

apply_filters( 'woocommerce_taxonomy_objects_product_cat',array( 'product' ) ),

apply_filters(

'woocommerce_taxonomy_args_product_cat',

array(

'hierarchical' => true,

'update_count_callback' => '_wc_term_recount',

'label' => __( '级别','woocommerce' ),

'labels' => array(

'name' => __( '级别',

'singular_name' => __( 'Category',

'menu_name' => _x( '级别','Admin menu name',

'search_items' => __( 'Search categories',

'all_items' => __( 'All categories',

'parent_item' => __( 'Parent category',

'parent_item_colon' => __( 'Parent category:',

'edit_item' => __( 'Edit category',

'update_item' => __( 'Update category',

'add_new_item' => __( 'Add new category',

'new_item_name' => __( 'New category name',

'not_found' => __( 'No categories found',

),

'show_ui' => true,

'query_var' => true,

'capabilities' => array(

'manage_terms' => 'manage_product_terms',

'edit_terms' => 'edit_product_terms',

'delete_terms' => 'delete_product_terms',

'assign_terms' => 'assign_product_terms',

'rewrite' => array(

'slug' => $permalinks['category_rewrite_slug'],

'with_front' => false,

'hierarchical' => true,

)

)

);

以上代码添加到主题 functions 里,效果如下图我们添加一个 级别 字段:


以上内容由PHP站长网【52php.cn】收集整理供大家参考研究如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读