在 Woocommerce 中获取产品名称 [英] Get the product name in Woocommerce

查看:69
本文介绍了在 Woocommerce 中获取产品名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够通过使用 PHP 通过产品 ID 回显产品名称来显示产品标题(这将显示在页面中,而不是产品页面本身).我正在使用 Wordpress 并且我有一个 PHP 插件,因此我可以使用 [php]echo 'example';[/php]

I want to be able to display a product title by using PHP to echo the product name by the product ID (this is to be displayed within a Page, not the product page itself). I am using Wordpress and I have a plugin for PHP so I can include PHP code using [php]echo 'example';[/php]

一个产品示例是;http://ukcctvinstallations.co.uk/product/1-摄像头住宅系统高分辨率/

当我编辑产品时,您可以在 URL 中看到 'Post' = 129 那么我说这是产品 ID 对吗?

When I edit the product, you can see in the URL that the 'Post' = 129 so am I right in saying this is the product ID?

如果有人对此有解决方案,将不胜感激.我正在使用 WooCommerce.

If anyone has a solution for this, that would be much appreciated. I am using WooCommerce.

推荐答案

找到解决方案:-

echo get_the_title('ID');

看看这里:http://docs.woothemes.com/wc-apidocs/package-WooCommerce.Functions.Product.html

这篇关于在 Woocommerce 中获取产品名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆