我想根据4列(桌面视图)、2列(mobile view 768px)和1列(mobile view 425px)的组合显示帖子。我在下面找到了很棒的代码:
<?php
$paged = ( get_query_var(\'paged\') ) ? get_query_var(\'paged\') : 1;
$args=array(
\'post_type\' => \'post\',
\'posts_per_page\' => 8,
\'paged\' => $paged,
\'tax_query\' => array(
array(
\'taxonomy\' => \'post_format\',
\'field\' => \'slug\',
\'terms\' => array(\'post-format-video\'),
\'operator\' => \'IN\')
)
);
$my_query = null;
$my_query = new WP_Query($args); ?>
<?php if( $my_query->have_posts() ) {
$i = 0;
while ($my_query->have_posts()) : $my_query->the_post();
if($i % 4 == 0) { ?>
<div class="row">
<?php
}
?>
<?php get_template_part( \'template/loop\', \'video\' ); ?>
<?php $i++;
if($i != 0 && $i % 4 == 0) { ?>
</div><!--/.row-->
<div class="clearfix"></div>
<?php
} ?>
<?php endwhile; } wp_reset_query();?>
它可以在桌面视图(4列)上完美运行;(1列425px),但不在移动视图中(2列768px)。有人能帮忙吗?谢谢