Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.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
Php WordPress自定义帖子类型查询显示_Php_Wordpress_Twitter Bootstrap_Custom Post Type - Fatal编程技术网

Php WordPress自定义帖子类型查询显示

Php WordPress自定义帖子类型查询显示,php,wordpress,twitter-bootstrap,custom-post-type,Php,Wordpress,Twitter Bootstrap,Custom Post Type,我有一个自定义的帖子类型,我有一个查询,它工作得很好,除了它没有显示我想要的方式。我希望我的项目连续显示3个。我使用的是引导,出于某种原因,它将它们堆叠起来,而不是一行显示。我检查了标记,它正在为每个项目创建一个新div和一个新行。我尝试过使用循环,但它仍然以相同的方式显示项目。以下是我正在使用的代码: <div class="container portfolio"> <?php $args = array( 'post_typ

我有一个自定义的帖子类型,我有一个查询,它工作得很好,除了它没有显示我想要的方式。我希望我的项目连续显示3个。我使用的是引导,出于某种原因,它将它们堆叠起来,而不是一行显示。我检查了标记,它正在为每个项目创建一个新div和一个新行。我尝试过使用循环,但它仍然以相同的方式显示项目。以下是我正在使用的代码:

<div class="container portfolio">  
    <?php  
      $args = array( 'post_type' => 'projects', 'posts_per_page' => 30);
      $the_query = new WP_Query( $args );
    ?>
    <?php if ( $the_query->have_posts() ) : ?>
    <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    <div class="row js--wp-4">
      <div class="col-md-4">
        <div class="card">
          <img src="<?php the_field('background_img_small'); ?>" alt="" class="site-image">
          <div class="overlay text-center">
            <h2 class="card-title"><?php the_title(); ?></h2>
            <p class="card-info"><?php the_field('short_desc'); ?></p>
            <div class="d-flex justify-content-center align-items-center">
                <a href="portfolio-single.html"><button type="button" class="btn btn-md btn-outline-secondary">View Project</button></a>
            </div>
          </div>
        </div>
      </div> 
    </div>
    <?php endwhile;
    wp_reset_postdata(); ?>
    <?php else: ?>
    <p><?php _e( 'Sorry there are no posts' ); ?></p>
    <?php endif; ?>   
  </div>

“alt=”“class=”站点图像“>

以下是需要显示的方式:

下面是它现在的测试方式,有三个测试柱:

已解决。我刚在循环中找到了行,它一直在新的一行中显示每个项目。哎呀,下面是正确的代码:

<div class="container portfolio"> 
        <?php  
          $args = array( 'post_type' => 'projects' );
          $the_query = new WP_Query( $args );
        ?>

        <div class=" row js--wp-4">

          <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>  

          <div class="col-md-4">                            
            <div class="card">          
              <img src="<?php the_field('background_img_small'); ?>" alt="" class="site-image">
              <div class="overlay text-center">
                <h2 class="card-title"><?php the_title(); ?></h2>
                <p class="card-info"><?php the_field('short_desc'); ?></p>
                <div class="d-flex justify-content-center align-items-center">
                    <a href="portfolio-single.html"><button type="button" class="btn btn-md btn-outline-secondary">View Project</button></a>
                </div>
              </div>
            </div>                  
          </div> 
        
           <?php endwhile;
            wp_reset_query(); ?> 
            
        </div>         
    </div> 
   </div>

“alt=”“class=”站点图像“>