モデレーター
まーちゅう
(@rocketmartue)
woocommerceの関数wc_get_template_part
を使用して
<?php
// the query
$args = array(
'post_type' => 'product',
'posts_per_page' => 8,
'orderby' => 'date',//日付順 更新日にするなら'modified'
'order' => 'DESC'
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) : ?>
<!-- the loop -->
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="product-content">
<?php wc_get_template_part( 'content', 'product' ); ?>
</div>
<?php endwhile; ?>
<!-- end of the loop -->
<?php wp_reset_postdata();
endif; ?>
こんな感じで、表示できます。
トピック投稿者
saito
(@paddock-gate)
ありがとうございます!
無事表示させることができたのですが、スタイルがだいぶ崩れるんですね…。
WooCommerceのデフォルトの商品ページのように並ばせる方法はあるのでしょうか?
モデレーター
まーちゅう
(@rocketmartue)
テーマがBootstrapを利用しているようなので、スタイリングはそれほど難しくはないと思います。
http://getbootstrap.com/
http://bootstrap3.cyberlab.info/
参考までに、コードをあげておきます。
<section id="product" class="new-product">
<div class="container">
<div class="row">
<?php
// the query
$args = array(
'post_type' => 'product',
'posts_per_page' => 8,
'orderby' => 'date',//日付順 更新日にするなら'modified'
'order' => 'DESC'
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) : ?>
<!-- the loop -->
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="col-md3 col-sm-6 col-xs-12">
<div class="product-content">
<?php wc_get_template_part( 'content', 'product' ); ?>
</div>
</div>
<?php endwhile; ?>
<!-- end of the loop -->
</div>
</div>
</section>
英語ですが、テーマのホームページにドキュメンテーションもありますので、目を通しておくといいと思います。
http://docs.themeisle.com/
トピック投稿者
saito
(@paddock-gate)
ご丁寧にありがとうございました!
どうにか表示させることができました。ありがとうございます!