如何在woocommerce循环中获取自定义产品类型中的产品数据?
我的定制产品类型是:tour如何在woocommerce循环中获取自定义产品类型中的产品数据?,woocommerce,product,Woocommerce,Product,我的定制产品类型是:tour $args = array( 'post_type' => 'product', 'posts_per_page' => 25, 'tax_query' => array( array( 'taxonomy' => 'product_type', 'field' => 'sl
$args = array(
'post_type' => 'product',
'posts_per_page' => 25,
'tax_query' => array(
array(
'taxonomy' => 'product_type',
'field' => 'slug',
'terms' => 'tour',
),
),
);
$products = new WP_Query($args);
如何在top查询中的woocommerce循环中获取自定义产品类型数据(日期和日期以及活动/非活动和…)
谢谢您应该创建自定义产品类型并将自定义字段添加到产品设置中 然后,要获得这些值,只需使用流行的
get\u post\u meta()
函数。这就是你所需要的
例如:
<?php
// Display Custom Field Value
echo get_post_meta( $post->ID, 'my-field-slug', true );
// You can also use
echo get_post_meta( get_the_ID(), 'my-field-slug', true );
?>
您应该创建自定义产品类型,并将自定义字段添加到产品设置中 然后,要获得这些值,只需使用流行的
get\u post\u meta()
函数。这就是你所需要的
例如:
<?php
// Display Custom Field Value
echo get_post_meta( $post->ID, 'my-field-slug', true );
// You can also use
echo get_post_meta( get_the_ID(), 'my-field-slug', true );
?>