2016-02-13 159 views
0

我能夠在worspress顯示下一個和以前的帖子,但無法顯示第二先前或第三先前||再下一個或第三下一個像在WordPress,如何顯示下一個和以前的帖子

1 - 我要顯示這個太
2 - 這被示出
3 - 我的當前交
4 - 這是表示
5 - 我想說明這太

任何幫助,將不勝感激。 在和我向你展示我的代碼,所以你可以判斷。

CODE:

<?php $next = get_permalink(get_adjacent_post(false,'',false)); if 
($next != get_permalink()) { ?><a href="<?php echo $next; ?>"> 
    <li class="col-xs-12 col-md-4"> 
     <div class="article"> 
      <div class="contain-image"> 
      <?php $nextPost = get_next_post(true); $nextthumbnail = get_the_post_thumbnail($nextPost->ID); echo $nextthumbnail; ?> 
      </div> 
      <div class="content"> 
       <div class="double-content"> 
        <div class="information"> 
         <span class="category"><?php echo get_cat_name(1);?></span> 
         <span class="time"><?php the_time('M j, Y') ?></span> 
        </div> 
        <div class="title"> 
         <?php next_post_link('%link', "%title", TRUE); ?> 
        </div> 
        <p> 
         <?php 
         $Nextpost = get_next_post($id); 
         echo apply_filters(‘the_content’, $Nextpost->post_content); 
         ?> 
        </p> 
       </div> 
      </div> 
     </div> 
    </li> 
</a> 
<?php } ?> 
<?php $prev = get_permalink(get_adjacent_post(true,'',true)); if 
($prev != get_permalink()) { ?><a href="<?php echo $prev; ?>"> 
    <li class="col-xs-12 col-md-4"> 
     <div class="article"> 
      <div class="contain-image"> 
      <?php $prevPost = get_previous_post(true); $prevThumbnail = get_the_post_thumbnail($prevPost->ID); echo $prevThumbnail; ?> 
      </div> 
      <div class="content"> 
       <div class="double-content"> 
        <div class="information"> 
         <span class="category"><?php echo get_cat_name(1);?></span> 
         <span class="time"><?php the_time('M j, Y') ?></span> 
        </div> 
        <div class="title"> 
         <?php previous_post_link('%link', "%title", TRUE); ?> 
        </div> 
        <p> 
        <?php 
         $Prevpost = get_previous_post($id); 
         echo apply_filters(‘the_content’, $Prevpost->post_content); 
         ?> 
        </p> 
       </div> 
      </div> 
     </div> 
    </li> 
</a> 
<?php } ?> 

回答

0

WordPress的提供了多種導航模板標籤,以方便遊客瀏覽你的網頁。基本上有用於時間後導航兩種不同類型的模板標籤:

posts_nav_link() – for navigating various archive (non-single) pages 
previous_post_link() & next_post_link() – for navigating single-post pages 


<?php $posts = query_posts($query_string); if (have_posts()) : while (have_posts()) : the_post(); ?> 

    <?php previous_post_link(); ?> | <?php next_post_link(); ?> 

<?php endwhile; endif; ?> 
+0

有一個變量錯誤 – qarar

0

試試這個:

global $post; 
    $post_curr = $post; 

    //get last post 
    $post_last1 = get_previous_post(); 
    setup_postdata($post_last1); 
    //get second last post 
    $post_last2 = get_previous_post(); 


    setup_postdata($post_curr); 
    //get next post now 
    $post_next1 = get_next_post(); 
    setup_postdata($post_next1); 
    //get second next post 
    $post_next2 = get_next_post(); 

    //reset current post data 
    setup_postdata($post_curr); 
+0

嗨,你說我沒有,但沒有happend – qarar

相關問題