I am using the following in a plugin to create a custom post type:
function post_type_listing() {
$labels = array(
'name' => _x('Listing', 'post type general name', 'themesdojo'),
'singular_name' => _x('Listing', 'post type singular name', 'themesdojo'),
'add_new' => _x('Add New Listing', 'book', 'themesdojo'),
'add_new_item' => __('Add New Listing', 'themesdojo'),
'edit_item' => __('Edit Listing', 'themesdojo'),
'new_item' => __('New Listing', 'themesdojo'),
'view_item' => __('View Listing', 'themesdojo'),
'search_items' => __('Search Listing', 'themesdojo'),
'not_found' => __('No Listing found', 'themesdojo'),
'not_found_in_trash' => __('No Listing found in Trash', 'themesdojo'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
//'rewrite' => true,
'rewrite' => array(
'slug' => 'view',
'with_front' => true
),
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','thumbnail','author', 'comments', 'amenities'),
'menu_icon' => 'dashicons-menu'
);
register_post_type( 'item', $args );
}
add_action('init', 'post_type_listing');
Note the custom rewrite for taxonomy at:
'rewrite' => array(
'slug' => 'view',
'with_front' => true
),
For some reason those post types are still showing URL of http://example.com/item/%post_name%/.
I’m at a loss. I’ve saved Permalinks and cleared cache. No dice.
It could very well be because of a plugin that alters the url, I know that add-this plugin does this. I would advice looking at your installed wordpress plugins.