2012-04-27 120 views
0
<div class="content" style="min-height:1022px;"> 
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
<div class="singlepost"> 
<h1 class="page-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </h1> 
<div class="post_info"> 
<p><?php the_time('Y年n月j日') ?> 
<span>/ </span> 
<?php comments_popup_link('0 comment', '1 comment', '% comments', '', 'closed'); ?> 
<span>/ </span> 
<?php the_category(', ') ?> 
</p> 
</div> 
<div class="post1"> 
<div class="post1text"> 
<!-- Post Content --> 
<?php the_content(); ?> 
</div> 
</div> 
<p class="clearfix" style="margin-left:20px;"><?php previous_posts_link('&lt;&lt; TheNewer', 0); ?> <span class="float right"><?php next_posts_link('ThePast &gt;&gt;', 0); ?></span></p> 
</div> 
<?php endwhile; else : ?> 
<?php endif; ?> 
<div class="cleared"></div>  
</div> 

上面的代碼是我的single.php顯示的內容,但它顯示每一頁相同的內容,所以,它有什麼問題?是循環?非常感謝〜爲什麼wordpress主題中的single.php,每頁都顯示相同的內容?

+0

我不認爲有環路 – 2012-04-27 10:19:10

+0

任何問題,有什麼不對您的循環,在頭會發生什麼? – janw 2012-04-27 11:17:13

回答

0

一旦你理解了基本的模板選擇層次結構,這應該讓你開始。 http://codex.wordpress.org/Template_Hierarchy

您也可以創建頁面模板,它非常簡單實用。 http://codex.wordpress.org/Pages#Creating_your_own_Page_Templates

最後,一旦你有所有的工作,你可以開始做一些真正聰明的東西與條件標籤。 http://codex.wordpress.org/Conditional_Tags

而不是你的代碼嘗試在single.php中這個簡單的代碼

  <div class="content" style="min-height:1022px;"> 
      <?php while (have_posts()) : the_post(); ?> 

       <nav id="nav-single"> 
        <h3 class="assistive-text"><?php _e('Post navigation', 'twentyeleven'); ?></h3> 
        <span class="nav-previous"><?php previous_post_link('%link', __('<span class="meta-nav">&larr;</span> Previous', 'twentyeleven')); ?></span> 
        <span class="nav-next"><?php next_post_link('%link', __('Next <span class="meta-nav">&rarr;</span>', 'twentyeleven')); ?></span> 
       </nav><!-- #nav-single --> 

       <?php get_template_part('content', 'single'); ?> 

       <?php comments_template('', true); ?> 

      <?php endwhile; // end of the loop. ?> 
     </div> 
+0

希望你使用WordPress 3.0或以上版本的兒童主題爲二十幾歲。 – Libin 2012-04-27 14:36:29

相關問題