2015-09-11 82 views
0

我想有一個博客頁面最多包含4個帖子,用戶可以看到其他帖子,當他按鏈接舊帖子,但我不能讓這個工作,當我按下它的鏈接直接到一個空白頁,這是我的代碼:在博客頁面顯示最舊的帖子php

<?php 
    $args = array('numberposts' => 4); 
    $posts= get_posts($args); 
    if ($posts) { 
     foreach ($posts as $post) { ?> 

     <article> 
      <header> 
      <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> 
      </header> 

      <footer> 
      <p><?php the_time('j F Y'); ?> 
      <!-- <br>Publié par <?php the_author_meta('display_name', 1); ?></p> --> 
      </footer> 


      <div> 
      <?php //echo catch_content_image($post->post_content) ?> 
      <?php the_excerpt() ?> 
      <a href="<?php the_permalink(); ?>">Suite de l'article</a> 
      </div> 
     </article> 
     <?php 
     } 
    } 
    ?> 

<nav> 
    <ul> 

    <li class="older"><a href="blog-2.html">← Articles précédents</a></li> 


    </ul> 
</nav> 

回答

1

我相信你的問題是這一行。

<li class="older"><a href="blog-2.html">← Articles précédents</a></li> 

嘗試使用這樣的事情,而不是:

$prev = get_previous_posts_link(); 
echo $prev; 

或前進

echo get_next_posts_link('Go to next page',4); 

你可以得到的,這裏的更多信息: https://codex.wordpress.org/Function_Reference/get_next_posts_link

相關問題