2013-05-30 53 views
0

我有一个WordPress的网站:有一个分页的问题..当我点击第2页时,它显示了第一个(索引页)。其他页面正在工作。你可以帮我吗? 我在循环中查找错误,但我没有找到任何东西!WordPress的分页

这是我的index.php代码

<?php get_header(); ?> 
    <div id="content"> 
    <?php if(get_option('freshlife_featured_content_enable') == 'on') { ?> 
     <div id="featured-content"> 
      <div class="heading"> 
       <span class="heading-text"><?php _e('Featured Articles', 'themejunkie'); ?></span> 
      </div> <!-- end .heading --> 
      <ul> 
       <?php 
        $counter = 1; 
        query_posts(array(
         'showposts' => get_option('freshlife_featured_post_num'), 
         'tag' => get_option('freshlife_featured_post_tags')   
        ));  
        if(have_posts()) : while(have_posts()) : the_post(); 
       ?> 
        <li class="featured-<?php echo $counter; ?>"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_post_thumbnail('featured-thumb', array('class' => 'entry-thumb')); ?></a><span class="entry-date"><abbr title="<?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?>"><?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . __(' ago', 'themejunkie'); ?></abbr></span><h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2></li> 
       <?php $counter++; endwhile; endif; wp_reset_query(); ?> 
      </ul> 
     </div> <!-- end #featured-content --> 
    <?php } ?> 
    <div class="heading"> 
     <span class="heading-text"><?php _e('All Stories', 'themejunkie'); ?></span> 
    </div> <!-- end .heading --> 
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
     <?php include(TEMPLATEPATH. '/includes/templates/loop.php'); ?> 
    <?php endwhile; ?> 
    <div class="clear"></div> 
    <?php if (function_exists('wp_pagenavi')) wp_pagenavi(); else { ?> 
     <div class="pagination"> 
      <div class="left"><?php previous_posts_link(__('Newer Entries', 'themejunkie')) ?></div> 
      <div class="right"><?php next_posts_link(__('Older Entries', 'themejunkie')) ?></div> 
      <div class="clear"></div> 
     </div> <!-- end .pagination --> 
    <?php } ?> 
    <?php else : ?> 
    <?php endif; ?> 
</div> <!-- end #content --> 
<?php get_sidebar(); ?> 
<?php get_footer(); ?> 

回答

0

很难不看由请求产生的WP_Query说。

但是我确实发现了一些可能导致问题的东西,query_posts改变了主查询,这可能会破坏分页。

尝试使用get_posts代替query_posts,因此主循环不受影响。

更详细的解释可以参考here

+0

谢谢。现在它工作了! –