dongxixian7803 2012-04-27 10:03
浏览 27

为什么word.php在wordpress主题中,每个页面显示相同的内容?

<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>  

Above code is my single.php which display the content, but it's display every page the same content, so, what's wrong with it? is the loop? Thanks very much~

  • 写回答

1条回答 默认 最新

  • doujing5150 2012-04-27 14:32
    关注

    It's so easy once you understand the basic template selection hierarchy, which should get you started. http://codex.wordpress.org/Template_Hierarchy

    You can also create page templates, it's really very simple and useful. http://codex.wordpress.org/Pages#Creating_your_own_Page_Templates

    And finally once you have got all that working, you can start doing some really clever stuff with conditional tags. http://codex.wordpress.org/Conditional_Tags

    Instead of your code try this simple code in 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>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用