Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress网格PHP_Php_Css_Wordpress_Grid_Blogs - Fatal编程技术网

Wordpress网格PHP

Wordpress网格PHP,php,css,wordpress,grid,blogs,Php,Css,Wordpress,Grid,Blogs,我在向项目中添加网格布局时遇到了一个问题,代码如下: <?php while ( have_posts() ) : the_post(); ?> <?php $args = array( 'post_type' => 'projects', 'posts_per_page' => 2, ); $q = new WP_Query( $args );

我在向项目中添加网格布局时遇到了一个问题,代码如下:

<?php while ( have_posts() ) : the_post(); ?>
    <?php
        $args = array(
            'post_type'      => 'projects',
            'posts_per_page' => 2,
        );
        $q    = new WP_Query( $args );
    ?>

    <div class="row">
        <?php while ( $q->have_posts() ) : $q->the_post(); ?>
            <div class="col-6">
                <h3>
                    <a href="<?php the_permalink(); ?>">
                        <?php the_title(); ?>
                    </a>
                </h3>
                <?php the_excerpt(); ?>
            </div>
        <?php endwhile; ?>
        <?php wp_reset_postdata(); ?>
    </div>

<?php endwhile; ?>

它看起来像这样:。它只是重复2列网格的次数,就像我有帖子一样多

谁能帮我解决这个问题,为我的项目获得一个正常的网格布局


谢谢

从顶部移除
,从底部移除
。因为在该循环中有一个自定义WP查询。所以这里不需要默认的Wordpress post查询循环。

应该是单行吗?完成,对不起,我是新来的。