I want to change my custom post URL. I want to remove “item” from URL.
With the below code and with custom post type url plugin http://wordpress.org/plugins/custom-post-type-permalinks/
my URL is:
Original URL : http://mywebsite/wp/item/america/mayer/
Want to change it to http://mywebsite/wp/america/mayer/
Without using 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');