Weblog

previous_post_link[前後ページへのリンク]

前後に記事が無い場合

$previous_post = get_previous_post();
$next_post = get_next_post();

if($previous_post||$next_post){
  echo &#039;<ul class=&quot;page_nav&quot;>&#039;;
  if(!empty($previous_post)){
    previous_post_link(&#039;<li class=&quot;prev&quot;>&amp;laquo; %link</li>&#039;,&#039;%title&#039;);
  }
  if(!empty($next_post)){
    next_post_link(&#039;<li class=&quot;next&quot;>&amp;raquo; %link</li>&#039;,&#039;%title&#039;);
  }
echo &#039;</ul>&#039;;
}

$previous_post = get_previous_post(true);
$next_post = get_next_post(true);

if($previous_post||$next_post){
  echo &#039;<ul class=&quot;page_nav&quot;>&#039;;
  if(!empty($previous_post)){
    previous_post_link(&#039;<li class=&quot;prev&quot;>&amp;laquo; %link</li>&#039;,&#039;%title&#039;,true);
  }
  if(!empty($next_post)){
    next_post_link(&#039;<li class=&quot;next&quot;>&amp;raquo; %link</li>&#039;,&#039;%title&#039;,true);
  }
echo &#039;</ul>&#039;;
}