Help us understand the problem. What is going on with this article?

個人的wordpressメモ:ページャー

More than 3 years have passed since last update.

シングルページでページャーを表示

single-hoge.php
<?php $previous_post = get_previous_post();
if (!empty( $previous_post )): ?>
<a href="<?php echo get_permalink( $previous_post->ID ); ?>">前へ</a>
<?php endif; ?>

<?php $next_post = get_next_post();
if (!empty( $next_post )): ?>
<a href="<?php echo get_permalink( $next_post->ID ); ?>">次へ</a>
<?php endif; ?>

アーカイブページでページャーを表示

archive-hoge.php
<?php
$previous_post = get_previous_posts_link();
if (!empty( $previous_post )): ?>
<a href="<?php echo get_previous_posts_page_link(); ?>">前へ</a>
<?php endif; ?>

<?php
$next_post = get_next_posts_link();
if (!empty( $next_post )): ?>
<a href="<?php echo get_next_posts_page_link(); ?>">次へ</a>
<?php endif; ?>

get_previous_post()、get_next_post()はシングルページ、
get_previous_postslink()、get_nextposts_linkはアーカイブページ

373skn
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away