我想更改我的自定义帖子URL。我想删除“item“”来自URL。
使用以下代码和自定义帖子类型url插件http://wordpress.org/plugins/custom-post-type-permalinks/我的URL是:
原始URL:http://mywebsite/wp/item/america/mayer/
要将其更改为http://mywebsite/wp/america/mayer/
不使用htaccess
.
WordPress Code
function aitDirItemPostType() {
register_post_type( \'ait-dir-item\',
array(
\'labels\' => array(
\'name\' => \'Items\',
\'singular_name\' => \'Item\',
\'add_new\' => \'Add new\',
\'add_new_item\' => \'Add new item\',
\'edit_item\' => \'Edit item\',
\'new_item\' => \'New item\',
\'not_found\' => \'No items found\',
\'not_found_in_trash\' => \'No items found in Trash\',
\'menu_name\' => \'Items\',
),
\'description\' => \'Manipulating with items\',
\'public\' => true,
\'show_in_nav_menus\' => true,
\'supports\' => array(
\'title\',
\'thumbnail\',
\'author\',
\'editor\',
\'excerpt\',
\'comments\',
),
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_icon\' => AIT_FRAMEWORK_URL . \'/CustomTypes/dir-item/dir-item.png\',
\'menu_position\' => $GLOBALS[\'aitThemeCustomTypes\'][\'dir-item\'],
\'has_archive\' => true,
\'query_var\' => \'dir-item\',
\'rewrite\' => array(\'slug\' => \'item\'),
\'capability_type\' => \'ait-dir-item\',
\'map_meta_cap\' => true
)
);
aitDirItemTaxonomies();
flush_rewrite_rules(false);
}
add_action( \'init\', \'aitDirItemPostType\');