前提・実現したいこと
php初心者です。
wordpressのテンプレートを作成しています。
記事の一覧表示を1ページに15件表示させて、
それ以上はページネーションを表示させたいのですが、
ページネーションがどうしても表示されません。
間違っているところを教えて下さい。
よろしくお願いいたします。
<?php get_header(); ?> <div id="contents" > <div class="contents-table site-width" > <div class="contents-left" > <div id="content-detail" > <section> <?php if(is_front_page()) : ?> <?php else : ?> <h1 class="entry-title"><?php the_title(); ?></h1> <?php endif ?> <div> <?php $newslist = get_posts( array( 'category_name' => 'topics', //特定のカテゴリースラッグを指定 //'tag' => 'slug', //特定のタグスラッグを指定 //'post_type' => 'slug', //特定のカスタム投稿タイプスラッグを指定 //'taxonomy' =>'slug', //特定のカスタムタクソノミースラッグを指定 //'term' =>'slug', //特定のカスタムタクソノミー内のタームスラッグを指定 //'terms' => array( 'slug1', 'slug2' ), //特定のカスタムタクソノミー内のタームスラッグを複数指定 'posts_per_page' => 15 //取得記事件数 )); foreach( $newslist as $post ): setup_postdata( $post ); ?><div class="blog01"><h4><a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a></h4> <div class="time"> <?php the_time('Y年n月j日'); ?></div> <section class="post-content txt" itemprop="text"> <?php if( get_the_post_thumbnail() ) { ?> <div class="post-thumbnail"> <a href="<?php the_permalink(); ?>" rel="nofollow"><?php the_post_thumbnail(); ?></a> </div> <?php } ?> <a href="<?php the_permalink(); ?>"><?php the_excerpt(); ?></a> </section> </div> <?php endforeach; wp_reset_postdata(); ?> </section> </div> <div class="pagenation"> <?php global $wp_query; $big = 999999999; echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), 'total' => $wp_query->max_num_pages ) ); ?> </div> </div> <div class="contents-right" > <?php get_sidebar(); ?> </div> </div> </div> <!-- #end contents --> <?php get_footer();?>
回答1件
あなたの回答
tips
プレビュー