2013-05-02 30 views
2

是我創造了自己的頁面模板頁面上一個新的博客頁面我遇到的問題,被稱爲blog.php的,我已經拉5帖到每個頁面的第一頁工作的高度,並鏈接到一個職位,他們是也附。WP-PageNavi問題,URL的變化,但職位保持不變?

當我嘗試將wp-pagenavi添加到我的nav-below時,遇到問題。會發生什麼事,我會點擊進入下一個頁面,它的URL改變了,但職位仍然和以前一樣,當它應該被他們切換到下一組。

我不知道你是否可以在index.php之外使用wp-pagenavi,但是如果有人能讓我知道我在這裏做錯了什麼,爲什麼我繼續得到相同的帖子,讚賞。我有我的博客blog.php的一個,那就是我試圖得到工作的文件。我已經在下面發佈了它的代碼。

<?php 
/** 
* Template Name: Blog Page <?php query_posts("posts_per_page=8"); ?> 
*/ 
get_header(); ?> 

    <div id="content"> 
    <?php query_posts(array('post_type' => 'post', 'posts_per_page=5')); ?> 
    <?php 
    //THE LOOP. 
    if(have_posts()): 
     while(have_posts()): 
     the_post(); ?> 

     <article id="post-1" <?php post_class('clearfix'); ?>> 
      <h2 class="entry-title"> <a href="<?php the_permalink(); ?>"> 
       <?php the_title(); ?> 
      </a></h2> 
      <div class="postmeta"> 
       <span class="author"> Posted by: <?php the_author(); ?> </span> 
       <span class="date"> <?php the_date(); ?> </span> 
       <span class="num-comments"> 
      <?php comments_number('No comments yet', 'One comment', '% comments'); ?></span> 
       <span class="categories"> 
        <?php the_category(); ?>     
       </span> 
       <span class="tags"> 
        <?php the_tags(); ?> 
       </span> 
      </div><!-- end postmeta --> 

      <?php if(has_post_thumbnail()): ?> 
      <div class="thumb"> 
       <?php the_post_thumbnail('thumbnail'); ?> 
      </div> 
      <?php endif; ?>   

      <div class="entry-content"> 
       <?php 
      if(is_single() OR is_page()): 

        the_content(); 

       else: 

        the_excerpt(); 

       endif; 

       ?> 
      </div> 


     <?php comments_template(); ?> 
     </article><!-- end post --> 
     <?php 
     endwhile; 
     else: ?> 
     <h2>Sorry, no posts found</h2> 
     <?php endif; //END OF LOOP. ?> 


     <div id="nav-below" class="pagination"> 
     <?php if(function_exists('wp_pagenavi')): 
       wp_pagenavi(); 
      else: 
      ?> 

      <?php next_posts_link('&larr; Older Posts'); ?> 
      <?php previous_posts_link('Newer Posts &rarr;'); ?> 

      <?php endif; ?> 
     </div><!-- end #nav-below --> 
    </div><!-- end content --> 

<?php get_footer(); ?> 
+0

multipost:http://stackoverflow.com/questions/16345510/wp-pagenavi-not-working-it-changes-the-actual-url -but-not-posts-themselve – diggy 2013-05-02 19:29:32

回答

2

<div id="content">後有這樣的代碼:

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?> 
<?php query_posts(array('post_type' => 'post', 'posts_per_page=5', 'paged' => $paged)); ?> 
+0

非常感謝您的支持!我一直在試圖找出非常感謝你這東西一會兒!!!!!!! – 2013-05-02 20:29:57