admin管理员组文章数量:1392007
I am looking for a way to pull(export) product post data (WooCommerce) using a shortcode by Product post ID to another general post
(ex. product post title/string).
Thank you
I am looking for a way to pull(export) product post data (WooCommerce) using a shortcode by Product post ID to another general post
(ex. product post title/string).
Thank you
Share Improve this question edited Mar 9, 2020 at 8:53 sleepingpanda 566 bronze badges asked Mar 8, 2020 at 18:10 LiorLior 11 Answer
Reset to default 0Add this code to your functions.php file and then you can use [product_title id="123"]
shortcode
If you want other product meta you can edit the function to return any product data you would want
/**
* Product title shortcode.
* `[product_title id="123"]` to get a specific product title, by ID
*
* @return string The post's title.
*/
add_shortcode( 'product_title', function( $atts ) {
$atts = shortcode_atts( array(
'id' => get_the_ID(),
), $atts, 'post_title' );
return get_the_title( absint( $atts['id'] ) );
});
本文标签: woocommerce offtopicWordpress shortcode to pull product post data
版权声明:本文标题:woocommerce offtopic - Wordpress shortcode to pull product post data 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744685388a2619667.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论