Php 显示来自Wordpress自定义帖子类型类别的帖子

Php 显示来自Wordpress自定义帖子类型类别的帖子,php,wordpress,post,Php,Wordpress,Post,我有一个自定义的帖子类型设置,称为推荐信和两个CPT类别设置,它们是客户推荐信和诊所推荐信 我试图只显示来自客户端TESTIMONALS CPT类别的帖子 为了实现这一点,我需要在下面添加什么 <div role="tabpanel" class="tab-pane fade" id="profile"> <?php query_posts('post_type=testimonials'); ?> <?php while

我有一个自定义的帖子类型设置,称为推荐信和两个CPT类别设置,它们是客户推荐信和诊所推荐信

我试图只显示来自客户端TESTIMONALS CPT类别的帖子

为了实现这一点,我需要在下面添加什么

 <div role="tabpanel" class="tab-pane fade" id="profile">
          <?php query_posts('post_type=testimonials'); ?>
          <?php while ( have_posts() ) : the_post(); ?>
          <div class="testimonial-holder wrap ">
            <div class="three-quarters">
              <h2>
                <?php the_title(); ?>
              </h2>
              <div class="testi">
                <?php the_content(); ?>
              </div>
            </div>
            <div class="four-col right center">
              <div class="testimonial-autor-image"> <img src="<?php the_field('author_image_or_clinic_logo'); ?>"   alt="Author Image">
                <div class="mt20">
                  <?php the_field('testimonial_author'); ?>
                </div>
              </div>
            </div>
          </div>
          <?php endwhile; // end of the loop. ?>
        </div>

“alt=”作者图像“>

您可以使用类似的方法

<?php
$type = 'testimonials';
$args=array(
  'post_type' => $type,
   'category'=>'CPT',
  'post_status' => 'publish'
);

$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
  while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <div class="testimonial-holder wrap ">
        <div class="three-quarters">
          <h2>
            <?php the_title(); ?>
          </h2>
          <div class="testi">
            <?php the_content(); ?>
          </div>
        </div>
        <div class="four-col right center">
          <div class="testimonial-autor-image"> <img src="<?php the_field('author_image_or_clinic_logo'); ?>"   alt="Author Image">
            <div class="mt20">
              <?php the_field('testimonial_author'); ?>
            </div>
          </div>
        </div>
      </div>
    <?php
  endwhile;
}

?>

“alt=”作者图像“>

谢谢,您将在本手册中从何处定义CPT类别?我正在将此代码添加到网站主页您的两类代码是什么?