最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

functions - I want to display the sku in the product pages of my EDD website

programmeradmin0浏览0评论

In the functions.php I use:

add_shortcode( 'output_post_sku', 'get_sku' );

And retrieve it with shortcode: [output_post_sku]

It doesn't work. Anyone familiar with this?

Thank you!

In the functions.php I use:

add_shortcode( 'output_post_sku', 'get_sku' );

And retrieve it with shortcode: [output_post_sku]

It doesn't work. Anyone familiar with this?

Thank you!

Share Improve this question asked Feb 25, 2020 at 11:57 BrentBrent 1 1
  • 1 Where is the code for get_sku? Is the SKU coming from EDD or somewhere else? When you say it doesn't work, can you be more specific? PHP fatal error? White screen of death? Empty output? Incorrect output? – Tom J Nowell Commented Feb 25, 2020 at 14:24
Add a comment  | 

1 Answer 1

Reset to default 0

SKU display on product detail page. Add this code in functions.php

add_action( 'woocommerce_single_product_summary', 'show_sku', 5 );
function show_sku(){
    global $product;
    echo 'SKU: ' . $product->get_sku();
}

发布评论

评论列表(0)

  1. 暂无评论