使用此查询显示woocommerce特色产品并替换为您的产品
$meta_query = WC()->query->get_meta_query();
$meta_query[] = array(
\'key\' => \'_featured\',
\'value\' => \'yes\'
);
$featured = array(
\'post_type\' => \'product\',
\'stock\' => 1,
\'showposts\' => 6,
\'orderby\' => \'date\',
\'order\' => \'DESC\',
\'meta_query\' => $meta_query
);
然后在循环中运行滑块动作html代码。
<?php $i = 0; ?>
<?php if( $featured->have_posts() ): while( $featured->have_posts() ): $featured->the_post(); ?>
<?php #$class = get_post_meta( get_the_ID(), \'class\', true); ?>
<?php if( $i === 1 ): ?>
<div class="col-md-6 col-lg-6 d-none d-sm-none d-md-block featured-desc">
<h2 class="featured-title-right text-right"><?php the_title(); ?></h2>
<p class="featured-excerpt-right text-right"><?php echo get_the_excerpt(); ?></p>
</div>
<div class="col-md-6 col-lg-6 text-center d-none d-sm-none d-md-block featured-img">
<img class="img-fluid" src="<?php the_post_thumbnail_url(); ?>">
</div>
<?php else: ?>
<div class="col-md-6 col-lg-6 text-center d-none d-sm-none d-md-block featured-img">
<img class="img-fluid" src="<?php the_post_thumbnail_url(); ?>">
</div>
<div class="col-md-6 col-lg-6 d-none d-sm-none d-md-block featured-desc">
<h2 class="featured-title"><?php the_title(); ?></h2>
<p class="featured-excerpt"><?php echo get_the_excerpt(); ?></p>
</div>
<?php endif;?>
<?php $i++; ?>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>