本文介绍了Woocommerce:如何从 id 中获取产品 slug?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前在购物车中有可用的产品 ID,我需要检索 slug.我该怎么做?
I currently have the product id available in the cart and I need to retrieve the slug. How can I do this?
推荐答案
您可以使用 get_post
$product = get_post( 27 );
$slug = $product->post_name;
echo $slug;
这篇关于Woocommerce:如何从 id 中获取产品 slug?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!