我正在尝试显示一个页面,其中包含同一类别ID内的相关帖子(FAQ)。当前该页面显示所有自定义帖子,但类别不同。
例如:-页面具有类别ID“4”。-页面有内容-在内容下有一个FAQ,需要显示页面的相同类别(4)
我的代码:
          <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
      <div class="content">
        <div class="white-block white-bg shadow">
          <div class="col-md-12">
            <div class="row">
              <div class="col-md-9 order-md-last">
                <div class="col-md-12 text-block light-grey">
                <h1><?php the_title(); ?><br />
                  <small><?php edit_post_link(); ?></small>
                  <?php the_category(); ?>
                </h1>
                <?php the_content(); ?>
    <?php
                        $query = new WP_Query( array( \'post_type\' => \'faq\', \'cat\' => $cat_id, \'posts_per_page\' => \'3\', \'post_status\'=>published,) );
                          while ( $query->have_posts() ) : $query->the_post();
                       ?>
                       <a href="<? the_permalink(); ?>" class="list-group-item list-group-item-action ">
                         <div class="col-12">
                           <div class="row">
                        <h5><?php the_title(); ?></h5>
                      </div>
                      <div class="row">
                          <small><?php the_date(); ?></small>
                      </div>
                      </div>
                        <p class="mb-1">
                          <?php echo(get_the_excerpt()); ?></p>
                      </a>
                     <?php endwhile; ?>
                <?php wp_link_pages(); ?>
            <h3> FAQ </h3>
            <?php wp_reset_query(); ?>
<?php
                    $query = new WP_Query( array( \'post_type\' => \'faq\', \'cat\' => $cat_id, \'posts_per_page\' => \'3\', \'post_status\'=>published,) );
                      while ( $query->have_posts() ) : $query->the_post();
                   ?>
                   <a href="<? the_permalink(); ?>" class="list-group-item list-group-item-action ">
                     <div class="col-12">
                       <div class="row">
                    <h5><?php the_title(); ?></h5>
                  </div>
                  <div class="row">
                      <small><?php the_date(); ?></small>
                  </div>
                  </div>
                    <p class="mb-1">
                      <?php echo(get_the_excerpt()); ?></p>
                  </a>
                 <?php endwhile; ?>
 我做错了什么?