質問: new wp_query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?> <li> <?php if ( has_post_thumbnail( $loop->post->id ) ) echo get_the_post_thumbnail( $loop->post->id, 'shop_catalog' ); else echo '<img src="' . woocommerce_placeholder_img_src() . '" alt="placeholder" width="65px" height="115px" />'; ?> <h3><?php the_title(); ?></h3> <?php echo $product->get_price_html(); woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?> </li> <?php endwhile; wp_reset_query(); ?>
回答: 引数を次のように変更してください。$meta_query = wc()->query->get_meta_query(); $meta_query[] = array( 'key' => '_featured', 'value' => 'yes' ); $args = array( 'post_type' => 'product', 'stock' => 1, 'showposts' => 6, 'orderby' => 'date', 'order' => 'desc', 'meta_query' => $meta_query ); wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php(@ 595)にアクセスすると、wcショートコードの処理方法がわかります。