私はWordPressの専門家ではないので、誰かが私を助けることができるかどうか疑問に思っています. 1 つのページのカスタム ページ テンプレートを作成して、そのページの 1 つのカテゴリからの投稿を集約して表示できるようにしました。しかし、今までそのカテゴリで 1 つの投稿を作成したのに、ページに 2 回表示されてしまいました。カテゴリから取り込まれた投稿は、「div id=main」div に表示されます。ページ テンプレートのコードは次のとおりです。
<?php /* Template Name: Deals Page */ ?>
<?php get_header(); ?>
</div>
//<?php while ( have_posts() ) : the_post(); ?>
<div id="title-bar">
<h1 class="bar-entry-title container"><?php the_title(); ?></h1>
</div>
<?php endwhile; ?>
<div class="container col-md-12"><!-- restart previous section-->
<div id="primary" class="content-area col-md-8">
<main id="main" class="site-main" role="main">
<?php query_posts('category_name=deals &posts_per_page=20'); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_title( '<h2>', '</h2>' ); ?>
<?php the_content(); ?>
//<?php get_template_part( 'content', 'page' ); ?>
<?php endwhile; // end of the loop. ?>
<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() )
comments_template();
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_sidebar('footer'); ?>
<?php get_footer(); ?>
投稿が 2 回表示される理由がわかりましたか? 理由がわかりません。