我想在我的博客页面中列出“blog”类别的默认WP帖子的标题,该页面具有“blog”标题并使用页面blog。php作为模板,其中包含以下代码:
<article>
 <?php
   $args = array (
    \'post_type\' => \'post\',
    \'category_name\' => \'blog\'
  );
   $query = new WP_Query( $args );
    if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query-   >the_post();
  ?>
  <h1><?php the_title(); ?></h1>
 <?php
  endwhile;
   wp_reset_postdata();
  else :
 ?>
  <p><?php _e( \'Sorry, no posts matched your criteria.\' ); ?></p>
  <?php endif; ?>
</article>
 无论我尝试什么,它都会显示所有WP帖子,无论它们分配到哪个类别。。。即使相同的代码可以完美地用于我的自定义帖子类型。。。
请帮忙!谢谢