0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Posted at

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

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はアーカイブページ

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?