wp-pagenavi插件中的错误

时间:2012-02-24 04:30:15

标签: wordpress wordpress-plugin

我已从此位置下载了wp-pagenavi。 http://wordpress.org/extend/plugins/wp-pagenavi/installation/。我正在使用wordpress 3.3.1。我已按照说明安装了此插件。我在home.php中使用了以下代码来显示帖子和分页。

<?php
/**
 * Template Name: Home Page
 */
get_header(); 


?>

<?php include(TEMPLATEPATH."/sidebar.php");?>

    <div id="content_right">
    <?php if ( function_exists('yoast_breadcrumb') ) {
    yoast_breadcrumb('<div id="breadcrumbs">','</div>');
} ?>
<div class="clear">&nbsp;</div>
<?php 
// Display most recent posts

$the_query = new WP_Query( "showposts=5" );
$postcount = 0;
while ( $the_query->have_posts() ) : $the_query->the_post();
$postcount++;
 ?>

<div class="blog_left">
<div><?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
  the_post_thumbnail();
} 
?>

</div>
</div>
<div class="blog_right">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div>in: <?php the_category(', ') ?></div>
<?php the_excerpt(); ?>
</div>
 <div class="clear"></div>

<?php
if( $postcount != 5){?> 
 <p class="blogdivider"></p>

<?php } ?>

<?php endwhile; 
$count = 0;
?>
<?php wp_pagenavi(); ?>

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

但是我的网页中没有显示分页。我无法追踪缺少的东西。有什么建议吗?

2 个答案:

答案 0 :(得分:0)

尝试

        <?php

$paged = intval(get_query_var('paged'));

if($paged == 0) {

$paged = 1;

}

?>

$the_query = new WP_Query( "showposts=5,get_query_var=paged" );

答案 1 :(得分:0)

此表格有效:

 //if not exists assigns value 1
 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 

 //query 5 posts
 query_posts("posts_per_page=5&paged=$paged");