我不确定我在这里遗漏了什么,cpt存档页面根本不想显示。我重置永久链接(默认情况下为currenlty),复制archive.php
并重命名为archive-articles.php
(测试了我能想到的任何东西)但是custom template 不想显示。It加载default archive.php、 2017年测试。这个single-article.php
现成的,但不是存档的。
/****************************************
* Add custom taxonomy for Articles *
****************************************/
add_action(\'init\', \'articles_categories_register\');
function articles_categories_register() {
$labels = array(
\'name\' => \'Articles Categories\',
\'singular_name\' => \'Articles Category\',
\'search_items\' => \'Search Articles Categories\',
\'popular_items\' => \'Popular Articles Categories\',
\'all_items\' => \'All Articles Categories\',
\'parent_item\' => \'Parent Article Category\',
\'edit_item\' => \'Edit Article Category\',
\'update_item\' => \'Update Article Category\',
\'add_new_item\' => \'Add New Article Category\',
\'new_item_name\' => \'New Article Category\',
\'separate_items_with_commas\' => \'Separate articles categories with commas\',
\'add_or_remove_items\' => \'Add or remove articles categories\',
\'choose_from_most_used\' => \'Choose from most used articles categories\'
);
$args = array(
\'label\' => \'Articles Categories\',
\'labels\' => $labels,
\'public\' => true,
\'hierarchical\' => true,
\'show_ui\' => true,
\'show_in_nav_menus\' => true,
\'args\' => array( \'orderby\' => \'term_order\' ),
\'rewrite\' => array( \'slug\' => \'articles\', \'with_front\' => true, \'hierarchical\' => true ),
\'query_var\' => true
);
register_taxonomy( \'articles_categories\', \'articles\', $args );
}
/*****************************************
* Add custom post type for Articles *
*****************************************/
add_action(\'init\', \'articles_register\');
function articles_register() {
$labels = array(
\'name\' => \'Articles\',
\'singular_name\' => \'Article\',
\'add_new\' => \'Add New\',
\'add_new_item\' => \'Add New Article\',
\'edit_item\' => \'Edit Article\',
\'new_item\' => \'New Article\',
\'view_item\' => \'View Article\',
\'search_items\' => \'Search Articles\',
\'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,
\'has_archive\' => true,
\'rewrite\' => array( \'slug\' => \'articles\', \'with_front\' => true ),
\'capability_type\' => \'post\',
\'menu_position\' => 6,
\'supports\' => array(\'title\', \'excerpt\', \'editor\',\'thumbnail\') //here you can specify what type of inputs will be accessible in the admin area
);
register_post_type( \'articles\' , $args );
}