2012-04-27 114 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

相关问题