Wordpress テーマHabakiriで子テーマを作って制作しています。
Advanced Custom Fieldsを使って、eventsという「イベント情報」を表示するページを
アーカイブページで作り、一覧表示まではできました。
ですが、テーマ標準のページングですと
2ページ目が1ページ目と同じになってしまいます。
試したこと
・アーカイブページでの記事取得数と
WP管理画面でのブログ表示数を揃えました。
・ページング機能自体は通常のカテゴリ一覧ページでは有効でした。
・似たようなケースの解決方法が無いか、
ネットで【wordpress 2ページ目 同じ】や
【カスタム投稿 2ページ目 同じ】で出てくる方法は
一通り試してみました。
補足情報(FW/ツールのバージョンなど)
子テーマのイベントアーカイブページ(archive-events.php)のテンプレートの中身です。
<?php /** * Version : 1.3.0 * Author : inc2734 * Author URI : http://2inc.org * Created : April 20, 2015 * Modified : November 7, 2015 * License : GPLv2 or later * License URI: license.txt */ ?> <?php get_header(); ?> <?php get_template_part( 'modules/page-header' ); ?> <div id="blogtop" class="sub-page-contents"> <div class="col-xs-12"> <h2 class="text-center" style="border:none;"><img src="<?php bloginfo('stylesheet_directory'); ?>/img/top/01_title-event.png" alt="イベント"></h2> </div> <div class="container"> <div class="row"> <div class="col-xs-9"> <main id="main" role="main"> <article class="article article--archive"> <div class="entry"> <?php do_action( 'habakiri_before_entries' ); ?> <div class="entries entries--archive"> <section id="top"> <div class="container-fluid"> <div class="row"> <div class="col-xs-12 co-3m"> <?php $args = array( 'post_type' => array('events'), ); $the_query = new WP_Query( $args ); ?> <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <div class="col-xs-12 co-3p ent-item"> <div class="col-xs-4 top_event"> <a href="<?php the_permalink(); ?>"> <div class="image_wrap"> <?php if ( has_post_thumbnail() ) { the_post_thumbnail("top-event_img"); } else{ echo ('<img src="'.get_template_directory_uri().'/img/common/nothumbnail.png" alt="サムネイルがありません。">'); } ?> </div></a> </div> <div class="col-xs-8 event_eventWrap2"> <p class="cat">カテゴリー:<?php echo get_the_term_list($post->ID,'events_cats'); ?></p> <a href="<?php the_permalink(); ?>"><p><?php the_title(); ?></p></a> <span class="data"><?php $field = the_field("data"); ?></span> <div class="description"><?php $field = the_field("event-description"); ?></div> </div> </div> <?php endwhile; endif; wp_reset_postdata(); ?> </div> </div> </div> </section> <!-- end .entries --></div> <?php do_action( 'habakiri_after_entries' ); ?> <?php get_template_part( 'modules/pagination' ); ?> <!-- end .entry --></div> </article> <!-- end #main --></main> <!-- end .col-md-9 --></div> <div class="col-md-3"> <?php get_sidebar('events'); ?> </div> <!-- end .row --></div> <!-- end .container --></div> <!-- end .sub-page-contents --></div> <?php get_footer(); ?>
続いて、親テーマにあるページング
(<?php get_template_part( 'modules/pagination' ); ?>)の中身になります。
<?php /** * Version : 1.0.1 * Author : inc2734 * Author URI : http://2inc.org * Created : September 9, 2015 * Modified : December 9, 2015 * License : GPLv2 or later * License URI: license.txt */ global $wp_rewrite; global $wp_query; global $paged; $paginate_base = get_pagenum_link( 1 ); 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 .= '%_%'; } $paginate_links = paginate_links( array( 'base' => $paginate_base, 'format' => $paginate_format, 'total' => $wp_query->max_num_pages, 'mid_size' => 5, 'current' => ( $paged ? $paged : 1 ), 'prev_text' => '<', 'next_text' => '>', 'type' => 'array', ) ); if ( !$paginate_links ) { return; } ?> <nav class="pagination-wrapper"> <ul class="pagination"> <?php foreach ( $paginate_links as $link ) : ?> <li><?php echo $link; ?></li> <?php endforeach; ?> </ul> </nav>
お手数をおかけいたしますが、
何卒よろしくお願い致します。。。
回答1件
あなたの回答
tips
プレビュー