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',
                '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(
                '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


add_action( 'init', 'aitDirItemPostType');
  • 1
    "item" is the basename for your custom post type. You can change it in this line of code 'rewrite' => array('slug' => 'item'), but you can't remove it. If you change it, remember you need to flush the rewrite rules afterwards by visiting the permalinks page in the administrative dashboard. – epilektric May 15 '14 at 13:12
  • no this is a theme code.and if i will change according to you then url will use air-dir-item in place of item. so another solution please.. – Johan May 15 '14 at 13:22

You can omit the "base", by adding

rewrite => array(
    slug       => 'item',
    with_front => false,

Don't forget to flush your rewrite rules after you changed that. The easiest way to do so it to simply visit the "admin > settings > permalinks" page.

If you need to add that to an already registered post type, then take a look at the internals of register_post_type() and the available hooks and filters in its source Link to GitHub: Make use of the registered_post_type action which comes with two arguments: $post_type and $args.


I think you have to set the slug value to an empty string like '', deleting item.

I think that @kaiser think that item is a generic string for the posts, and he suggest to not prepend that string to your custom post type permalink. That's a good idea. But item is the slug for the CPT, so that's why is not working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.