1

サイトにあるカスタム投稿タイプの 1 つが機能しなくなりました。データベース エントリはまだ存在しますが、投稿にアクセスできません。これは既知のパーマリンクの問題だと思いますが、非常に多くの投稿を見て、提供された解決策を試してみましたが、まだ問題に悩まされています.

私は、3 つの異なる単一ファイル ('single-author.php'、'single-book.php'、'single-event.php') にリダイレクトするいくつかの並べ替えコードを含む 'single,php' ファイルを持っています。

私が試したこと:

  • パーマリンク構造の切り替えと元への切り替え
  • 書き換えルールのフラッシュ
  • .htaccess の書き換えルールを確認する

このカスタム投稿タイプで新しいエントリを作成すると、「プレビュー」で表示されますが、公開するとすぐに 404 が表示されます。この問題は、サイトで実行している他のカスタム投稿タイプには影響していないようです。 . 最近の WP の更新以外に、サイトに変更を加えていません。

以下に関連するコードを添付します。問題を解決するために他に何を試すべきかわからないため、ポインタやヘルプをいただければ幸いです。

どうもありがとう!

add_action('init', 'authors_register');

function authors_register() {

$labels = array(
    'name' => _x('Authors', 'post type general name'),
    'singular_name' => _x('Author', 'post type singular name'),
    'add_new' => _x('Add New', 'portfolio item'),
    'add_new_item' => __('Add New Author'),
    'edit_item' => __('Edit Author'),
    'new_item' => __('New Author'),
    'view_item' => __('View Author'),
    'search_items' => __('Search Authors'),
    'not_found' =>  __('Nothing found'),
    'not_found_in_trash' => __('Nothing found in Trash'),
    'parent_item_colon' => ''
);

$args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'menu_position' => 5,
    'supports' => array('title','thumbnail','revisions','excerpt'),
    'taxonomies' => array('category', 'post_tag')
  ); 

register_post_type( 'author' , $args ); 

}

single.php のコードの並べ替え/切り替え:

<?php if ('post_type=book') { include (TEMPLATEPATH . '/single-book.php'); } 

elseif ('post_type=event') { include (TEMPLATEPATH . '/single-event.php'); } 

elseif ('post_type=author') { include (TEMPLATEPATH . '/single-author.php'); } 

else { include (TEMPLATEPATH . '/single-post.php'); } ?>
4

1 に答える 1