我想使用Php将我的产品作为网格加载
我正在构建一个站点,我想在桌面设备上加载所有产品,作为我想使用Php将我的产品作为网格加载,php,wordpress,twitter-bootstrap,woocommerce,backend,Php,Wordpress,Twitter Bootstrap,Woocommerce,Backend,我正在构建一个站点,我想在桌面设备上加载所有产品,作为col-md-6的网格,但我使用了下面的代码,但加载方式不同。我该怎么办 <?php $params = array('posts_per_page' => 4, 'post_type' => 'product'); $wc_query = new WP_Query($params); ?> <?php if ($wc_query->have_posts()) : ?> <?php while
col-md-6
的网格,但我使用了下面的代码,但加载方式不同。我该怎么办
<?php
$params = array('posts_per_page' => 4, 'post_type' => 'product');
$wc_query = new WP_Query($params);
?>
<?php if ($wc_query->have_posts()) : ?>
<?php while ($wc_query->have_posts()) :
$wc_query->the_post(); ?>
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<?php the_post_thumbnail(); ?>
<h5><?php the_title(); ?><br>
<form><button class="button-default" type="submit"><a href="<?php the_permalink(); ?>"> View Product Details</button></form>
</div>
<div class="col-md-6">
<?php $row ?>
</div>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p>
<?php _e( 'No Products'); ?>
</p>
<?php endif; ?>
您需要在循环之外定义容器类。试试这个
<div class="container-fluid">
<div class="row">
<?php
$params = array('posts_per_page' => 4, 'post_type' => 'product');
$wc_query = new WP_Query($params);
?>
<?php if ($wc_query->have_posts()) : ?>
<?php while ($wc_query->have_posts()) :
$wc_query->the_post(); ?>
<div class="col-md-6">
<?php the_post_thumbnail(); ?>
<h5><?php the_title(); ?><br>
<form><button class="button-default" type="submit"><a href="<?php the_permalink(); ?>"> View Product Details</button></form>
</div>
<div class="col-md-6">
<?php $row ?>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p>
<?php _e( 'No Products'); ?>
</p>
<?php endif; ?>
</div>
</div>
你所说的“加载方式不同”是什么意思?@Hentry截图这是可能的?你是通过代码还是设计来解决问题的?@NicoHaase我希望每种产品每分钟加载两次row@Samyappa这是一个屏幕截图,我希望它如何加载和不加载你已经解决了我的问题。非常感谢!