###前提・実現したいこと
wordpressでcategory-column.phpページを作っています。
1ページ5記事でページネーションを作りたいのですが、
2ページ目に行ってもURLは変わるのですが、表示される記事が1ページ目と変わりません。
1ページ目のURL
http://ドメイン名/category/column/
2ページ目のURL
http://ドメイン名/category/column/page/2/
よろしくお願いします。
###category_column.phpのループ部分
php
1 2 3<div id="child_column_linkbox"> 4 <?php 5 $args = array( 'posts_per_page' => 5, 'category' => 'column', 'order' => 'DESC'); 6 $myposts = get_posts($args); 7 foreach( $myposts as $post) : setup_postdata($post); ?> 8<div class="child_column_article"> 9<div class="child_column_article_left"> 10<?php the_post_thumbnail('full', array('class' => 'column_relative')); ?> 11<?php 12 $days = 7; 13 $today = date_i18n('U'); 14 $entry = get_the_time('U'); 15 $elapsed = date('U',($today - $entry)) / 86400; 16 if( $days > $elapsed ){ 17 echo "<img src=\"/wp-content/themes/useful/shared/images/ico_01.png\" class=\"child_column_absolute\">"; 18 } 19?> 20</div> 21<div class="child_column_article_right"> 22<time><?php the_time('Y/n/d'); ?></time> 23<h2><?php the_title();?></h2> 24<p><?php echo mb_substr(strip_tags($post-> post_content),0,40).'...'; ?></p> 25<div class="child_column_article_more"> 26<a href="<?php the_permalink();?>"> 27<img src="<?php echo get_template_directory_uri(); ?>/shared/images/btn_03.png" alt=""> 28</a> 29</div> 30</div> 31</div> 32 33<?php endforeach; wp_reset_postdata();?> 34 35</div>
###category.phpページネーション出力部分
php
1<ul id="column_number"> 2<?php wp_pagination(); ?> 3</ul>
###functions.phpページネーション設定
php
1function wp_pagination() { 2 global $wp_query; 3 $big = 99999999; 4 $page_format = paginate_links( array( 5// 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 6 'format' => '?paged=%#%', 7// 'current' => max( 1, get_query_var('paged') ), 8 'total' => $wp_query->max_num_pages, 9 'prev_next' => True, 10 'prev_text' => __(' '), 11 'next_text' => __(' '), 12 'type' => 'array' 13 ) ); 14 if( is_array($page_format) ) { 15 $paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged'); 16 //echo '<li><span>'. $paged . ' of ' . $wp_query->max_num_pages .'</span></li>'; 17 foreach ( $page_format as $page ) { 18 echo "<li>$page</li>"; 19 } 20 } 21 wp_reset_query(); 22}

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/15 08:59
2016/10/15 09:14