我需要为单个类别制作一个循环。一切正常,除了我无法将页面拆分为多个部分。
这是我页面的循环。输出很好,除了导航栏不显示,只需将 /page/2 添加到 url 即可显示前 2 个帖子。
<?php query_posts('cat=179&posts_per_page=2'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'morlottiTabs' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<div class="entry-meta">
<?php morlottiTabs_posted_on(); ?>
</div>
<div class="entry-content">
<?php the_content(); ?>
</div><!-- .entry-content -->
<div class="entry-utility">
<?php morlottiTabs_posted_in(); ?>
<?php edit_post_link( __( 'Edit', 'morlottiTabs' ), '<span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-utility -->
</div>
<?php endwhile; endif; ?>
<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<div id="nav-below" class="navigation">
<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'morlottiTabs' ) ); ?></div>
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'morlottiTabs' ) ); ?></div>
</div><!-- #nav-below -->
<?php endif; ?>