好吧,我能想出来。虽然尤金·曼努伊洛夫的回答很好,可能对其他人有用,但不幸的是,它对我不起作用。对我来说,结束工作的是在我最后一次自定义帖子类型结束之前添加刷新重写。
function register_cpt_attorney() {
$labels = array(
\'name\' => _x( \'Attorneys\', \'attorney\' ),
\'singular_name\' => _x( \'Attorney\', \'attorney\' ),
\'add_new\' => _x( \'Add New Attorneys\', \'attorney\' ),
\'add_new_item\' => _x( \'Add New Attorney\', \'attorney\' ),
\'edit_item\' => _x( \'Edit Attorney\', \'attorney\' ),
\'new_item\' => _x( \'New Attorney\', \'attorney\' ),
\'view_item\' => _x( \'View Attorney\', \'attorney\' ),
\'search_items\' => _x( \'Search Attorneys\', \'attorney\' ),
\'not_found\' => _x( \'No attorneys found\', \'attorney\' ),
\'not_found_in_trash\' => _x( \'No attorneys found in Trash\', \'attorney\' ),
\'parent_item_colon\' => _x( \'Parent Attorney:\', \'attorney\' ),
\'menu_name\' => _x( \'Attorneys\', \'attorney\' ),
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => false,
\'description\' => \'Your Attorney page(s).\',
\'supports\' => array( \'thumbnail\' ),
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => false,
\'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\' => true,
\'capability_type\' => \'post\'
);
register_post_type( \'attorney\', $args );
// add the following function if you are getting
// a \'Page not found\' error from your permalink
flush_rewrite_rules( false );
}
add_action( \'init\', \'register_cpt_attorney\' );