如果列出$args数组会有所帮助,但您要查找的部分位于“重写”下。以下是我喜欢构建一个$args数组以注册帖子类型的方法:
// set up the labels
$labels = array(
\'name\' => _x(\'Archived Jobs\', \'post type general name\'),
\'singular_name\' => _x(\'Archived Job\', \'post type singular name\'),
\'add_new\' => __(\'Add New\'),
\'add_new_item\' => __(\'Add New Job\'),
\'edit_item\' => __(\'Edit Job\'),
\'new_item\' => __(\'New Job\'),
\'view_item\' => __(\'View Job\'),
\'search_items\' => __(\'Search Jobs\'),
\'not_found\' => __(\'No Jobs found\'),
\'not_found_in_trash\' => __(\'No Jobs found in Trash\'),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Archives\'
);
//set up the rewrite rules
$rewrite = array(
\'slug\' => \'archives\'
);
//build the arguement array
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => \'archives\',
\'rewrite\' => $rewrite,
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array(\'title\',\'editor\',\'author\',\'comments\')
);
register_post_type(\'archive\',$args);
您正在寻找的部分是$重写部分,将slug更改为您想要的任何内容(当然,url友好,没有奇怪的字符或空格)。您甚至可能希望在其中添加斜杠。在我的示例中,URL显示为:www.website。com/archives/post\\u名称/