这个问题有很多答案,甚至在这个网站上,但没有一个适合我。是的,我做了我所知道的所有事情,我从以前的答案中得到了答案,但我的自定义帖子类型存档不起作用:
<?php
function project_register_cpt_books() {
$labels = array(
\'name\' => __( \'Books\', \'textdomain\' ),
\'singular_name\' => __( \'Book\', \'textdomain\' ),
\'name_admin_bar\' => __( \'Books\', \'textdomain\' ),
\'add_new\' => __( \'Add New\', \'textdomain\' ),
\'add_new_item\' => __( \'Add New Book\', \'textdomain\' ),
\'edit_item\' => __( \'Edit Book\', \'textdomain\' ),
\'new_item\' => __( \'New Book\', \'textdomain\' ),
\'view_item\' => __( \'View Book\', \'textdomain\' ),
\'search_items\' => __( \'Search Books\', \'textdomain\' ),
\'not_found\' => __( \'No Book found\', \'textdomain\' ),
\'not_found_in_trash\' => __( \'No Book found in Trash\', \'textdomain\' ),
\'parent_item_colon\' => __( \'Parent Book:\', \'textdomain\' ),
\'menu_name\' => __( \'Books\', \'textdomain\' ),
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => false,
\'description\' => __( \'To get books information\', \'textdomain\' ),
\'supports\' => array( \'title\', \'editor\' ),
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\' => 5,
\'show_in_nav_menus\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'has_archive\' => true,
\'query_var\' => true,
\'can_export\' => true,
\'rewrite\' => array( \'slug\' => \'books\' ),
\'capability_type\' => \'post\'
);
register_post_type( \'books\', $args );
/**
* To Activate Custom Post Type Single page.
* @author Bainternet
* @link http://en.bainternet.info/2011/custom-post-type-getting-404-on-permalinks
* -----------
*/
$set = get_option(\'post_type_rules_flased_books\');
if ($set !== true){
flush_rewrite_rules(false);
update_option(\'post_type_rules_flased_books\',true);
}
}
add_action( \'init\', \'project_register_cpt_books\' );
激活/停用主题、刷新永久链接、检查默认和PostName永久链接、更改slug、更改/注释
rewrite
参数全部失败。我不可能
archive-books.php
正在工作。现在又回到了
archive.php
无论如何。
我怎样才能解决这个问题?