Пользовательский шаблон таксономии по умолчанию не выбран

Я зарегистрировал пользовательский тип сообщения faq и таксономию для faq именем cat_faq . Я создал шаблон с именем taxonomy-cat_faq.php , но по умолчанию он не выбран. Он всегда отображает страницу 404. Я не мог понять, почему так происходит? Я зачитал иерархию шаблонов и работал следующим образом, но не смог обнаружить ошибку. Я приложил код ниже

 add_action('init', 'register_faq'); function register_faq(){ $post_type = 'faq'; $label = array( 'name' => _x('FAQ', 'FAQ', 'faq'), 'singular_name' => _x('FAQ', 'FAQ', 'faq'), 'menu_name' => _x('FAQ', 'admin menu', 'faq') ); $args = array( 'labels' => $label, 'public' => true, 'rewrite' => array('slug' => 'faq'), 'capability' => 'post', 'supports' => array('title', 'editor', 'thumbnail'), ); register_post_type($post_type, $args); } // create taxonomies for the post type "faq" add_action( 'init', 'create_faq_taxonomies', 0 ); function create_faq_taxonomies() { $labels = array( 'name' => _x( 'FAQ', 'taxonomy general name' ), 'singular_name' => _x( 'FAQ', 'taxonomy singular name' ), 'search_items' => __( 'Search FAQ' ), 'edit_item' => __( 'Edit FAQ' ), 'update_item' => __( 'Update FAQ' ), 'add_new_item' => __( 'Add New FAQ' ), 'new_item_name' => __( 'New FAQ' ), 'menu_name' => __( 'Category FAQ' ), ); $args = array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'cat_faq' ), ); register_taxonomy( 'cat_faq', array( 'faq' ), $args ); } 

Solutions Collecting From Web of "Пользовательский шаблон таксономии по умолчанию не выбран"

Лучше создавать свои собственные типы сообщений таким образом. flush_rewrite_rules() вылечит 404. См. «Кодекс». Этот пример предназначен для создания новых настраиваемых типов сообщений при активации вашего плагина.

 add_action( 'init', 'my_cpt_init' ); function my_cpt_init() { register_post_type( ... ); } function my_rewrite_flush() { // First, we "add" the custom post type via the above written function. // Note: "add" is written with quotes, as CPTs don't get added to the DB, // They are only referenced in the post_type column with a post entry, // when you add a post of this CPT. my_cpt_init(); // ATTENTION: This is *only* done during plugin activation hook in this example! // You should *NEVER EVER* do this on every page load!! flush_rewrite_rules(); } register_activation_hook( __FILE__, 'my_rewrite_flush' );