嘿,大家好,首先我是一个WP新手,所以放轻松!
我已经找了几天了,想看看我是否能找到这个问题的答案,但没有任何确切的答案。
我有一个名为“documents”的自定义帖子类型和一个名为archive-documents.php
. 当我单击自定义分类法时,它会以默认的archive.php
样板
这里的代码functions.php
add_action(\'init\', \'documents_register\');
function documents_register() {
$labels = array(
\'name\' => _x(\'Documents\', \'post type general name\'),
\'singular_name\' => _x(\'Document\', \'post type singular name\'),
\'add_new\' => _x(\'Add New\', \'Document Entry\'),
\'add_new_item\' => __(\'Add New Document Entry\'),
\'edit_item\' => __(\'Edit Document Entry\'),
\'new_item\' => __(\'New Document Entry\'),
\'view_item\' => __(\'View Document Entry\'),
\'search_items\' => __(\'Search Documents\'),
\'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,
\'menu_icon\' => get_stylesheet_directory_uri() . \'/images/documents-icon.png\',
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'menu_position\' => null,
\'rewrite\' => array( \'slug\' => \'documents\' ),
\'has_archive\' => true,
\'supports\' => array(\'title\',\'editor\',\'thumbnail\'),
);
register_post_type( \'documents\' , $args );
register_taxonomy("types", array("documents"), array("hierarchical" => true, "label" => "Types", "singular_label" => "Type", "rewrite" => true));
}