我正在寻找回显数组的一部分,将数组的一部分回显到数据字段中的最佳方法是什么我有一个包含条款 => 订阅的数组,需要将该字段拉入我的输入 data-subscription="[echo subscription in here ]"$quantites_required = false;$previous_post = $post;$count = 0;$tax_query_args = [ 'post_type' => 'product', 'tax_query' => [ [ 'taxonomy' => 'product_type', 'field' => 'name', 'terms' => 'subscription', ], ],];$tax_query = get_posts($tax_query_args);global $grouped_product;foreach ($tax_query as $post) { global $post; $price = get_post_meta(get_the_ID(), '_price', true); ?><li id="product-<?php the_ID();?>" <?php post_class();?>> <div class="prod-name"> <div class="radio"> <input type="checkbox" id="product-<?php the_ID();?>" value="1" name="quantity[<?php the_ID();?>]" class="wc-grouped-product-add-to-cart-checkbox js-group-item-sel" <?php echo ($count != 0 ? '' : ' checked="checked"'); ?> data-subscription="[echo terms subrciptions here]" /> <label for="product-<?php the_ID();?>"> <?php echo the_title(); ?> </label> </div> </div> <div class="prod-price" data-price="<?php echo number_format($price, 2); ?>"> <p> <?php echo wc_price($price); ?> </p> </div> <div class="prod_flag"> <?php get_product_flags(true); //Hide featured for grouped child items. ?> </div> <?php$count = $count + 1;}$count = 0;
1 回答
侃侃尔雅
TA贡献1801条经验 获得超16个赞
替换这一行
<input type="checkbox" id="product-<?php the_ID();?>" value="1" name="quantity[<?php the_ID();?>]" class="wc-grouped-product-add-to-cart-checkbox js-group-item-sel" <?php echo ($count != 0 ? '' : ' checked="checked"'); ?> data-subscription="[echo terms subrciptions here]" />
和
<input type="checkbox" id="product-<?php the_ID();?>" value="1" name="quantity[<?php the_ID();?>]" class="wc-grouped-product-add-to-cart-checkbox js-group-item-sel" <?php echo ($count != 0 ? '' : ' checked="checked"'); ?> data-subscription="<?php echo ($tax_query_args['tax_query'][0]['terms']); ?>" />
- 1 回答
- 0 关注
- 128 浏览
添加回答
举报
0/150
提交
取消