我正在尝试从类别中提取最新的帖子;当地新闻;但我只看到这一类的两篇帖子中的一篇。我不确定是不是我的if语句和/或while循环导致了问题。这是我第一次开发WP主题并使用PHP,所以我对如何解决这个问题有点困惑。我不知道如何关闭if语句或while循环而不导致严重错误或语法错误。
<?php
  $args = array(
  \'category_name\' => \'local-news\',
  \'post_type\' => \'post\' ,
  \'orderby\' => \'date\' ,
  \'order\' => \'DESC\' ,
  \'posts_per_page\' => 6
  );
  $q = new WP_Query($args);
  $q -> the_post();
  ?>
  if ( $q->have_posts() ) : { 
    while ( $q->have_posts() ) : the_post() {
      <div class="card-body pb-0">
        <div class="latest_news_cont">
          <a href="<?php the_permalink() ?>">
            <?php the_post_thumbnail(); ?>
          </a>
          <a href="<?php the_permalink() ?>">
            <h5>
              <?php the_title(); ?>
            </h5>
          </a>
          <?php the_excerpt(); ?>
          <p style="text-align:center;"><a href="<?php the_permalink() ?>" class="readmore_news">Read more</a></p>
          <br>
        </div>
      </div>
      <div class="card-body pb-0">
        <div class="latest_news_cont">
          <a href="<?php the_permalink() ?>">
            <?php the_post_thumbnail(); ?>
          </a>
          <a href="<?php the_permalink() ?>">
            <h5>
              <?php the_title(); ?>
            </h5>
          </a>
          <?php the_excerpt(); ?>
          <p style="text-align:center;"><a href="<?php the_permalink() ?>" class="readmore_news">Read more</a></p>
          <br>
        </div>
      </div>