2013-05-30 88 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

謝謝。現在它工作了! –