在我的Wordpress主题中,如何为博客页面添加分页?

时间:2012-02-09 23:45:08

标签: php html wordpress themes wordpress-theming

我目前将Wordpress设置为仅在博客页面中显示最新的5个帖子。 它正常工作,并根据需要显示后摘录。

唯一的问题是,第6个帖子根本没有显示,并且没有添加分页。 我需要一个'上一个/下一个'系统来显示其他页面,但无法找到如何在任何地方实现它。

目前的主题代码:

<?php 
    if (is_page()) {
        the_content();  
    }
    if (is_front_page()) {
        the_content();  
    }
    if ((is_single())) {
        echo '<h2 class="entry-title"><a href="'; echo the_permalink(); echo'" title="'; the_title(); echo '">'; the_title();
        echo '</a>';
        echo '</h2>';
        echo '<h6>'; the_excerpt(); '</h6>';
    }
    if ((is_home())) {
        echo '<h2 class="entry-title"><a href="'; echo the_permalink(); echo'" title="';         the_title(); echo '">'; the_title();
        echo '</a>';
        echo '</h2>';
        echo '<h6>'; the_excerpt(); '</h6>';
        echo '<h4>'; 
        echo '<a href="'; echo the_permalink();  echo '">';
        echo '<img src="'; bloginfo( 'template_directory' ); echo '/images/read_more.gif"         alt="Read more..." border="0" />';
        echo '</a>';
        echo '</h4>';
        echo '<hr />';
    }
?>        
<?php  ?>                 
</div>
<div class="body-bottom"></div>
</div>

<?php endwhile; ?>
</div>
</div>
</div>
<?php get_footer(); ?>

2 个答案:

答案 0 :(得分:2)

此插件对分页也很有用。

http://www.devdevote.com/cms/wordpress-plugins/wp-paging

您还可以使用wordpress默认分页代码:

答案 1 :(得分:1)

对于分页,您可以使用插件NAME WP-PageNavi插件。 插件网址: - http://wordpress.org/extend/plugins/wp-pagenavi/