我的分页页面在每一页上都显示出相同的内容。查询第一页以显示两篇文章,并正确显示。第二页显示了与第一页完全相同的两篇文章。这是我的代码:(functions.php)(这是我在web上找到的一个预制代码)。
function wp_corenavi() {
global $wp_query, $wp_rewrite;
$pages = \'\';
$max = $wp_query->max_num_pages;
if (!$current = get_query_var(\'paged\')) $current = 1;
$a[\'base\'] = str_replace(999999999, \'%#%\', get_pagenum_link(999999999));
$a[\'total\'] = $max;
$a[\'current\'] = $current;
$total = 1; //1 - display the text "Page N of N", 0 - not display
$a[\'mid_size\'] = 5; //how many links to show on the left and right of the current
$a[\'end_size\'] = 1; //how many links to show in the beginning and end
$a[\'prev_text\'] = \'« Previous\'; //text of the "Previous page" link
$a[\'next_text\'] = \'Next »\'; //text of the "Next page" link
if ($max > 1) echo \'<div class="navigation">\';
if ($total == 1 && $max > 1) $pages = \'<span class="pages">Page \' . $current . \' of \' . $max . \'</span>\'."\\r\\n";
echo $pages . paginate_links($a);
if ($max > 1) echo \'</div>\';
}
(自定义页面模板)<?php
get_header();
if ( have_posts() ) : ?>
<div id="container">
<div id="content" role="main">
<?php query_posts( \'category_name=category&showposts=2\'); ?>
<?php while ( have_posts() ) : the_post(); ?>
<div>
<div>
<div class="thumb">
<?php the_post_thumbnail(\'thumbnail\'); ?>
</div>
<h2 class="entry-title" style="text-align:center;"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( \'Permalink to %s\', \'twentyten\' ), the_title_attribute( \'echo=0\' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<div class="the-excerpt">
<?php echo content(15, __(\'(Read More)\')); /* twentyten_posted_on(); */ ?>
</div><!-- .entry-meta -->
</div>
</div>
<?php endwhile; // end of the loop. ?>
<br clear="all" />
<?php if (function_exists(\'wp_corenavi\')) wp_corenavi(); ?>
</div><!-- #content -->
</div><!-- #container -->
<?php endif; ?>