Possible Duplicate:
How to have a custom URL structure for a custom post type?

I create custom post type called "portfolio". Now I try to figure out url, for portfolio, and for standard posts. I want permalink like that:

sitename.com/portfolio/simple-project-name/ - for portfolio post type. sitename.com/blog/simple-post-name/ - for posts.

Now, my url for protfolio is fine, but for post i haven't a "/blog/" before post title. If I go to Permalink Settings in Dashboard and add "/blog/" to Custom Structure, it's works for posts, but for portfolio post type i have:

sitename.com/blog/portfolio/simple-project-name/ - but i don't want /blog/ for portfolio post type. How to fix it?


1 Answer 1


try to set rewrite as parameter in $args register_post_type function.


function codex_custom_init() {
    $labels = array(
        'name' => _x('Books', 'post type general name'),
        'singular_name' => _x('Book', 'post type singular name'),
        'add_new' => _x('Add New', 'book'),
        'add_new_item' => __('Add New Book'),
        'edit_item' => __('Edit Book'),
        'new_item' => __('New Book'),
        'all_items' => __('All Books'),
        'view_item' => __('View Book'),
        'search_items' => __('Search Books'),
        'not_found' => __('No books found'),
        'not_found_in_trash' => __('No books found in Trash'),
        'parent_item_colon' => '',
        'menu_name' => __('Books')
    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'query_var' => true,
        'rewrite' => array('slug' => 'porfolio'),
        'capability_type' => 'post',
        'has_archive' => true,
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments')
    register_post_type('book', $args);

add_action('init', 'codex_custom_init');

More here: http://codex.wordpress.org/Function_Reference/register_post_type

  • Yes, i set rewrite, when i create post type, but this does not solve the problem. I must find a way to add to url '/blog/' only, if it's single post page.
    – Jack
    Aug 23, 2012 at 8:59
  • The best and the fastest is to create another custom post type with 'blog' slug.
    – Mateusz
    Aug 24, 2012 at 11:26

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