Wordpress4.6.1にインストールした、Buddypress2.7.2 にカスタム項目をつくり、それに対応したページをつくり、そのページ内に、POSTタイプの記事を10件表示し、ページング機能をつくりましたが(やり方はこちらを参考にしました。)、ページング機能が動かずにこまっています。ページングのやり方は、Codexにあるやり方、で下記のコードのようにしています。ページングは表示されますが、2ページより、クリックしたあとに、ページが見つからない状態です。
1ページ目のURLは
http://example.com/member/username/custom/
2ページ目以降のリンク先は、
http://example.com/member/username/custom/page/2/
http://example.com/member/username/custom/page/3/
http://example.com/member/username/custom/page/4/ .... となっています。
<?php $paged = get_query_var('paged'); $args = array( 'posts_per_page' => 10, 'paged' => $paged, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish' ); $the_query = new WP_Query($args); if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php get_template_part( 'content', get_post_format() ); ?> <?php endwhile; ?> <?php $big = 999999999; // need an unlikely integer echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), 'total' => $the_query->max_num_pages ) ); ?> <?php else: ?> <?php get_template_part( 'content', 'none' ); ?> <?php endif; ?>
また、上記のようにPaginate_links()でページングを表示するのではなく、プラグイン「WP PageNavi」を利用して、echo paginate_links();の部分を
<?php if(function_exists('wp_pagenavi')){ wp_pagenavi(array('query'=>$the_query));} ?> <!--WP-NaviPage--!>
に変えて、ページング機能を表示させた場合も、同様に、ページングは表示はされますが、リンク先はプラグインを使わない場合と同じで、クリックしても、ページが見つからない状態です。
原因がよくわかならいので、もし心当たりがありましたらお手数ではございますが、ご教示ください。よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。