カスタムタクソノミーのタームのアーカイブページのページ送りが404になる

お力をお借りしたく、こちらに投稿させていただきます。

発生している現象

表題の通り、カスタム投稿タイプのカスタムタクソノミーに属するタームのアーカイブページで

ページ送り2ページ目が404になります。

基本情報

wordpress バージョン 5.4.1(現時点最新)

カスタム投稿タイプ AAA

カスタムタクソノミー AAA_cat

ターム BBB,CCC,DDD

パーマリンク構造

http://example.com/AAA/ AAAのアーカイブ

http://example.com/AAA/BBB/ タームBBBのアーカイブ

http://example.com/AAA/page/2/ AAAのアーカイブのページ送り2ページ目

上記は問題ないのですが、タームBBBのアーカイブページで出力されたページ送り

http://example.com/AAA/BBB/page/2/

以降が404になってしまいます。

上記パーマリンクを実現するため、プラグイン Custom Post Type Permalinksを使用。

本来であればタームBBBのアーカイブが

http://example.com/AAA_cat/BBB/

となるのを

http://example.com/AAA/BBB/ にしています。

(設定は後述します)

functions.phpの設定

functions.phpに以下の記述でカスタム投稿タイプとカスタムタクソノミーを設定しています。

functions.php

カスタム投稿タイプに関する記述

function create_post_type_column() {
  register_post_type( 'AAA',
    array(
      'label' => 'AAA',
      'labels' => array(
      'all_items' => 'AAA一覧'
      ),
      'public' => true,
      'has_archive' => true,
      'menu_position' => 10,
      'supports' => array( 'title', 'editor', 'author', 'thumbnail')
    )
  );
}
add_action( 'init', 'create_post_type_column' );

カスタムタクソノミーに関する記述

function add_taxonomy() {
          register_taxonomy(
            'AAA_cat',
            'AAA',
            array(
              'label' => 'AAAカテゴリ',
              'singular_label' => 'AAAカテゴリ',
              'labels' => array(
              'all_items' => 'AAAカテゴリ一覧',
              'add_new_item' => 'AAAカテゴリを追加'
              ),
              'public' => true,
              'show_ui' => true,
              'show_in_nav_menus' => true,
              'rewrite' => true,
              'rewrite' => array('slug' => 'AAA'), 
              'hierarchical' => true
              )
            );
        }
  add_action( 'init', 'add_taxonomy' );

Custom Post Type Permalinksの設定

パーマリンクを変更するため、Custom Post Type Permalinks

https://ja.wordpress.org/plugins/custom-post-type-permalinks/)で

http://exapmle.com/AAA/�A_cat%/%postname%/

has_archive: true / with_front: true

という設定にし、

カスタムタクソノミーのアーカイブに、 post_type クエリーを追加。

にチェックを入れています。

テンプレートファイルへの記述

続いてテンプレートファイルですが、

http://example.com/AAA/BBB/

には、taxonomy-AAA_cat.phpが適用されています。

以下がtaxonomy-AAA_cat.phpの記述です。

記事取得にはメインループを使用しており、WP_queryなどは使用していません。

taxonomy-AAA_cat.php

<?php if(have_posts()): while(have_posts()): the_post(); ?>
〜アーカイブ用記事の内容〜
<?php endwhile; ?><?php else: ?><?php endif; ?>
//以下ページャー部分
<?php
              $big = 9999999999;
              $arg = array(
              'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
              'current' => max( 1, get_query_var('paged') ),
              'total'   => $wp_query->max_num_pages,
              'prev_text'          => __('< PREV'),
              'next_text'          => __('NEXT >'),
              );
              echo paginate_links($arg);
?>

上記で問題なくページャーの出力はできていますが、いざページ送りをクリックすると、

http://exapmle.com/AAA/BBB/page/2/

が404になるという状態です。

・ページャーの出力は問題なくできていること

http://exapmle.com/AAA/page/2/ というカスタム投稿タイプのページ送りは問題なく表示できること

以上から、パーマリンク構造を変更した際のリライトルール周りのエラーだと推測していますが、

行き詰まっております。

#wordpress

What is GEEK

Buddha Community

カスタムタクソノミーのタームのアーカイブページのページ送りが404になる

カスタムタクソノミーのタームのアーカイブページのページ送りが404になる

お力をお借りしたく、こちらに投稿させていただきます。

発生している現象

表題の通り、カスタム投稿タイプのカスタムタクソノミーに属するタームのアーカイブページで

ページ送り2ページ目が404になります。

基本情報

wordpress バージョン 5.4.1(現時点最新)

カスタム投稿タイプ AAA

カスタムタクソノミー AAA_cat

ターム BBB,CCC,DDD

パーマリンク構造

http://example.com/AAA/ AAAのアーカイブ

http://example.com/AAA/BBB/ タームBBBのアーカイブ

http://example.com/AAA/page/2/ AAAのアーカイブのページ送り2ページ目

上記は問題ないのですが、タームBBBのアーカイブページで出力されたページ送り

http://example.com/AAA/BBB/page/2/

以降が404になってしまいます。

上記パーマリンクを実現するため、プラグイン Custom Post Type Permalinksを使用。

本来であればタームBBBのアーカイブが

http://example.com/AAA_cat/BBB/

となるのを

http://example.com/AAA/BBB/ にしています。

(設定は後述します)

functions.phpの設定

functions.phpに以下の記述でカスタム投稿タイプとカスタムタクソノミーを設定しています。

functions.php

カスタム投稿タイプに関する記述

function create_post_type_column() {
  register_post_type( 'AAA',
    array(
      'label' => 'AAA',
      'labels' => array(
      'all_items' => 'AAA一覧'
      ),
      'public' => true,
      'has_archive' => true,
      'menu_position' => 10,
      'supports' => array( 'title', 'editor', 'author', 'thumbnail')
    )
  );
}
add_action( 'init', 'create_post_type_column' );

カスタムタクソノミーに関する記述

function add_taxonomy() {
          register_taxonomy(
            'AAA_cat',
            'AAA',
            array(
              'label' => 'AAAカテゴリ',
              'singular_label' => 'AAAカテゴリ',
              'labels' => array(
              'all_items' => 'AAAカテゴリ一覧',
              'add_new_item' => 'AAAカテゴリを追加'
              ),
              'public' => true,
              'show_ui' => true,
              'show_in_nav_menus' => true,
              'rewrite' => true,
              'rewrite' => array('slug' => 'AAA'), 
              'hierarchical' => true
              )
            );
        }
  add_action( 'init', 'add_taxonomy' );

Custom Post Type Permalinksの設定

パーマリンクを変更するため、Custom Post Type Permalinks

https://ja.wordpress.org/plugins/custom-post-type-permalinks/)で

http://exapmle.com/AAA/�A_cat%/%postname%/

has_archive: true / with_front: true

という設定にし、

カスタムタクソノミーのアーカイブに、 post_type クエリーを追加。

にチェックを入れています。

テンプレートファイルへの記述

続いてテンプレートファイルですが、

http://example.com/AAA/BBB/

には、taxonomy-AAA_cat.phpが適用されています。

以下がtaxonomy-AAA_cat.phpの記述です。

記事取得にはメインループを使用しており、WP_queryなどは使用していません。

taxonomy-AAA_cat.php

<?php if(have_posts()): while(have_posts()): the_post(); ?>
〜アーカイブ用記事の内容〜
<?php endwhile; ?><?php else: ?><?php endif; ?>
//以下ページャー部分
<?php
              $big = 9999999999;
              $arg = array(
              'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
              'current' => max( 1, get_query_var('paged') ),
              'total'   => $wp_query->max_num_pages,
              'prev_text'          => __('< PREV'),
              'next_text'          => __('NEXT >'),
              );
              echo paginate_links($arg);
?>

上記で問題なくページャーの出力はできていますが、いざページ送りをクリックすると、

http://exapmle.com/AAA/BBB/page/2/

が404になるという状態です。

・ページャーの出力は問題なくできていること

http://exapmle.com/AAA/page/2/ というカスタム投稿タイプのページ送りは問題なく表示できること

以上から、パーマリンク構造を変更した際のリライトルール周りのエラーだと推測していますが、

行き詰まっております。

#wordpress