【WordPress】ページネーションを作る関数|the posts pagination
記事更新日:2022-09-10

関数を使って
ページネーション
作りたい
ページネーション
作りたい
ページネーションを設置したいところへ記述する

これだけでOK
<?php the_posts_pagination(array(
'mid_size' => 1,
'prev_text' => '前へ',
'next_text' => '次へ',
'screen_reader_text' => ''
)); ?>

mid_sizeは、現在ページの左右に表示するページ番号の数
the posts pagination
使い方 <?php the_posts_pagination( $args ); ?>
クラス名を変更したいとき

functions.phpに記述する
function custom_the_posts_pagination($template) {
$template = '
<nav class="(クラス名)" role="navigation">
<section class="(クラス名)">
<h2 class="screen-reader-text">%2$s</h2>
%3$s
</section>
</nav>
';
return $template;
}
add_filter('navigation_markup_template', 'custom_the_posts_pagination');
2022-09-10
編集後記:
この記事の内容がベストではないかもしれません。
記事一覧
-
絵文字を停止する 【WordPress】高速化|絵文字を読み込む設定を停止する -
function_existsで関数を作る 【WordPress】if (!function_exists()が必要な理由|子テーマでカスタマイズしやすくなる -
カテゴリ画像をサムネイルに 【WordPress】管理画面でカテゴリ別画像を登録・サムネイルに設定【メディアアップロード追加方法】 -
クラス名を変数でechoする 【WordPress】クラス名を変数にしてechoする -
ウィジェットでサイドバー 【WordPress】ウィジェットでサイドバーを作る -
パンくずリストを作る 【WordPress】パンくずリストを自作する