#概要
現在Wordpressでカスタム投稿のカスタムタクソノミー(カテゴリー)の一覧ページを固定ページを使って作ろうとしていて、ページ送りが2ページ目になる(『サイト名/固定ページ名(カスタムタクソノミー名)/page/2』)と404エラーを吐き出してしまい、ページ送りができません。
どなたか助けてください…!(>0<;;)
##ファイルの構成や設定について
ファイルの構成はこのようになっています。
■taxonomy-renovation_category.php(カスタムタクソノミー『リノベ種別』用)
■taxonomy-renovation_style.php(カスタムタクソノミー『スタイル種別』用)
(カスタム投稿のカスタムタクソノミーのアーカイブページ。
各タームの一覧は見られましたが、各カスタムタクソノミーごとの一覧は見れないため固定ページを代用しました)
■renovation_category.php(固定ページのカスタムテンプレート。一覧用に使う)
■renovation_style.php(固定ページのカスタムテンプレート。一覧用に使う)
プラグイン「Costom Post Type Ul」を使ってカスタム投稿タイプ『ギャラリー(gallery)』を作成し、
カテゴリーとして『リノベ種別(renovation_category)』『スタイル種別(renovation_style)』を指定しています。
パーマリンクは『サイト名/%post_id%』に設定しています。
カスタムフィールドは「Advanced Costom Field」を使っています。
固定ページ名はrenovation_categoryです。
ページナビはプラグインを使用していません。
カスタムテンプレートの内容は下記の通りです。
(WP_queryを使って呼び出しています)
PHP
1<?php 2/* 3Template Name: 固定ページ用 4*/ 5?> 6 7<?php get_header(); ?> 8<!--container--> 9<div id="container"> 10 <!--contents--> 11 <div class="contents"> 12 <article> 13 14 <section> 15 <div class="clearfix post"> 16 <!--topicPath"--> 17 <div id="topicPath"> 18 <div class="breadcrumbs" xmlns:v="http://rdf.data-vocabulary.org/#"> 19 <?php if(function_exists('bcn_display')) 20 { 21 bcn_display(); 22 }?> 23 </div> 24 </div> 25 <!--/topicPath"--> 26 27 <h2><?php wp_title(""); ?></h2> 28 29 <!-- loop --> 30 <ul class="report_ul"> 31 <?php 32 $paged = (int) get_query_var('paged'); 33 $args = array( 34 'posts_per_page' => '2', //表示件数。-1なら全件表示 35 'post_type' => 'gallery', //カスタム投稿タイプの名称を入れる 36 'post_status' => 'publish', //取得するステータス。publishなら一般公開のもののみ 37 'orderby' => 'post_date', //日付順に並び替え 38 'order' => 'DESC', 39 'tax_query' => array( 40 array( 41 'taxonomy' => 'renovation_category', 42 'field' => 'slug', 43 'terms' => array( 'category_otherplace', 'category_puchi' ,'category_full'), 44 ), 45 ), 46 'paged' => $paged 47 ); 48 $the_query = new WP_Query($args); 49 if ( $the_query->have_posts() ) : 50 while ( $the_query->have_posts() ) : $the_query->the_post(); 51 52 ?> 53 54 <li> 55 <div class="category_tit <?php 56 $term = array_pop(get_the_terms($post->ID, 'renovation_category')); 57 $term_p = $term->parent; 58 if ( ! $term_p == 0 ){ 59 $term = array_shift(get_the_terms($post->ID, 'renovation_category')); 60 } 61 echo esc_html($term->slug); 62 ?>"> 63 <a href="<?php bloginfo('url'); ?>/renovation_category/<?php 64 $term = array_pop(get_the_terms($post->ID, 'renovation_category')); 65 $term_p = $term->parent; 66 if ( ! $term_p == 0 ){ 67 $term = array_shift(get_the_terms($post->ID, 'renovation_category')); 68 } 69 echo esc_html($term->slug); 70 ?>"> 71 <?php 72 $term = array_pop(get_the_terms($post->ID, 'renovation_category')); 73 $term_p = $term->parent; 74 if ( ! $term_p == 0 ){ 75 $term = array_shift(get_the_terms($post->ID, 'renovation_category')); 76 } 77 echo esc_html($term->name); 78 ?> 79 </a> 80 </div> 81 <div class="box"> 82 <a href="<?php the_permalink(); ?>"> 83 <div class="inner"> 84 85 <figure> 86 <div style="background-image:url(<?php $cftimg = wp_get_attachment_image_src(get_post_meta($post->ID, 'renovation_img', true), 'large'); echo $cftimg[0]; ?>)"></div> 87 <figcaption class="title">続きを読む...</figcaption> 88 </figure> 89 </div> 90 </a> 91 </div> 92 93 <div class="txt"> 94 <p class="txt_time"><?php the_time('Y年n月j日'); ?></p> 95 <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> 96 97 </div> 98 </li> 99 100 <?php endwhile; ?> 101 <?php else : ?> 102 <!-- 投稿がなかった時 --> 103 <?php endif; ?> 104 <?php wp_reset_postdata(); ?> 105 106 <!-- /loop--> 107 </ul> 108 <!-- /loop--> 109 110 <!--ページ送り--> 111 <div class="pager"> 112 <?php global $wp_rewrite; 113 $paginate_base = get_pagenum_link(1); 114 if(strpos($paginate_base, '?') || ! $wp_rewrite->using_permalinks()){ 115 $paginate_format = ''; 116 $paginate_base = add_query_arg('paged','%#%'); 117 } 118 else{ 119 $paginate_format = (substr($paginate_base,-1,1) == '/' ? '' : '/') . 120 user_trailingslashit('page/%#%/','paged');; 121 $paginate_base .= '%_%'; 122 } 123 echo paginate_links(array( 124 'base' => $paginate_base, 125 'format' => $paginate_format, 126 'total' => $the_query->max_num_pages, 127 'mid_size' => 4, 128 'current' => max(1, $paged), 129 'prev_text' => '«', 130 'next_text' => '»', 131 )); 132 ?> 133 </div> 134 <!--/ページ送り--> 135 136 137 <?php get_template_part('parts','btmcontents') ?> 138 </div> 139 </section> 140 141 </article> 142 </div> 143 <!--/contents--> 144 145</div> 146<!--/container--> 147<?php get_footer(); ?>
上記お力をお貸しいただけましたら幸いです。
よろしくお願い致します。
###発生している問題
2ページ目になる(『サイト名/固定ページ名(カスタムタクソノミー名)/page/2』)と404エラーを吐き出してしまい、ページ送りができません。
###試したこと
- https://gist.github.com/hissy/6103177の記述を使う
- 『mux_num_pages』の記述を直してみる http://xtra-blog.net/pagination/
- プラグイン「Custom Post Type UI」を使う
- functions.phpを使って、/page/2の記述を消す…など
(解決できず詰んでいます)
おそらくページ送りするとき、『サイト名/固定ページ名/page/2』の固定ページをwp側が探し見つからないため404を吐き出していると思われます。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/08/08 00:54
2016/08/08 01:49
2016/08/08 03:12
2016/08/08 05:36
2016/08/08 10:55