###解決したいこと
index.phpの記事一覧にページ送りのコードを付けたのですが、うまく機能しません。最初の5件のページは表示されますが、2ページ目、3ページ目が記事一覧部分のみが白くなって表示されません。
###index.php
<?php get_header(); ?> <div class="container"> <div class="contents-wrapper"> <div class="contents"><!--contents--> <!--indexの表示記事、コードで指定するとカテゴリー、タグが機能しない--> <?php if(have_posts()):while(have_posts()):the_post(); ?><!--ループ開始--> <div class="page-title"> <a class="link" href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a><!--the_title(); 記事タイトルを表示--><!--the_permalink(); 記事タイトルから記事へのリンク--> </div><!--/.page-title--> <div class="category"> <i class="fa fa-tag" aria-hidden="true"> </i><?php the_category(',') ?><!--カテゴリーを表示--> </div><!--/.category--> <div class="date"> <?php the_time('Y/m/d(D) H:i'); ?><!--投稿日時を表示--> </div><!--/.date--> <div class="page"> <?php echo mb_substr($post->post_content,0,140).'...'; ?><!--記事本文を出力し140文字に制限する--> </div><!--/.page--> <div class="border"></div> <?php endwhile; endif; ?><!--ループ終了--> <!------------------------ページ送りここから------------------------------> <div class="index-pager"> <?php global $wp_rewrite; $paginate_base = get_pagenum_link(2); if(strpos($paginate_base, '?') || ! $wp_rewrite->using_permalinks()){ $paginate_format = ''; $paginate_base = add_query_arg('paged','%#%'); } else{ $paginate_format = (substr($paginate_base,-1,1) == '/' ? '' : '/') . user_trailingslashit('page/%#%/','paged');; $paginate_base .= '%_%'; } echo paginate_links(array( 'base' => $paginate_base, 'format' => $paginate_format, 'total' => $wp_query->max_num_pages, 'mid_size' => 4, 'current' => ($paged ? $paged : 1), 'prev_text' => '«', 'next_text' => '»', )); ?> </div><!--/.index-pager--> <!-------------------------ページ送りここまで-----------------------------------> </div><!--contentsクラス終了-->
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。