2010-07-07 5 views
1

내가했던 나의 홈 페이지에 하나의 게시물을 표시하려면 다음Wordpress를 작성하는 방법은 의견과 의견 양식이있는 첫 페이지에 단 하나의 게시물 만 표시 하시겠습니까?

home.php :

<?php 
get_header(); 
query_posts('posts_per_page=1'); //returns only the front page 
?> 

<div id="content"> 
    <?php 
    /* Run the loop to output the posts. 
    * If you want to overload this in a child theme then include a file 
    * called loop-index.php and that will be used instead. 
    */ 
    get_template_part('loop', 'index'); 
    ?> 
</div> 
<div id="sidebar"> 
    <?php get_sidebar(); ?> 
</div> 
<div id="footer"> 
<?php get_footer(); ?> 

하지만 난 여전히 의견과 양식을보기 위해 Comments을 클릭 ahave 코멘트를 남겨주세요. 즉시 자동으로 표시 할 수 있습니까?

답변

1

<?php comments_template(); ?>을 사용하여 댓글 템플릿을로드하면 현재 게시물의 모든 댓글을 표시합니다.

+0

죄송합니다. #content div 바로 앞에 해당 코드를 삽입했는데 아무 일도 없었습니다! – alexchenco

+0

루프를로드하기 전에 주석을 표시하려면'the_post()'를 호출하고 주석을로드 한 다음'rewind_posts()'를 사용하여 루프를 재설정하십시오. – TheDeadMedic

0
<?php get_header(); ?> 
    <div class="blog"> 
     <section> 
      <div class="container"> 
       <div class="row"> 
        <div class="blog-sidebar"> 
         <?php get_sidebar(); ?> 
        </div> 
        <div class="span8"> 
        <?php $articles = new WP_Query(array(
             'post_type' => 'post', 
             'post_status' => 'publish', 
             'posts_per_page' => 1 
            ));?> 
         <?php while ($articles->have_posts()): $articles->the_post(); ?> 
          <article id="post-<?php the_ID(); ?>" role="article"> 
           <header> 
            <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('wpbs-featured'); ?></a> 
           <section class="post_content clearfix" > 
            <?php the_content(); ?> 
           </section> 
          </article> 
         <?php endwhile; ?> 
         <?php comments_template('',true); ?> 
        </div> 
       </div> 
      </div> 
     </section> 
    </div> 

    <?php get_footer(); ?> 
관련 문제