Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible to use the permalink structure defined in the Wordpress settings panel for custom post types? And if so, how do I do that?

I currently have:

function add_posts_two() {
    $labels = array(
        'name' => 'Poststwo',
        'singular_name' => 'posttwo',
        'add_new' => __('New Posttwo'),
        'add_new_item' => __('New Posttwo'),
        'edit_item' => __('Edit Posttwo'),
        'new_item' => __('New Posttwo'),
        'all_items' => __('All Poststwo'),
        'view_item' => __('View Posttwo'),
        'search_items' => __('Search Poststwo'),
        'not_found' =>  __('No poststwo found'),
        'not_found_in_trash' => __('No poststwo found in Trash'),
        'parent_item_colon' => '',
        'menu_name' => 'Posttwo'
    );

    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'query_var' => true,
        'rewrite' => false,
        'capability_type' => 'post',
        'has_archive' => true,
        'hierarchical' => false,
        'taxonomies' => array("post_tag", "category"),
        'menu_position' => 5,
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
    );

    register_post_type( 'posttwo', $args );
}
add_action( 'init', 'add_posts_two' );
share|improve this question
The exact same permalink structure or a variation of it? You prob don't want to set a custom post type to the exact same permalink structure as your posts. – Cole Feb 18 at 14:45
Yeah, that is actually what I want to do. Why would you not want to do that? – Angelo A Feb 19 at 11:01

2 Answers

up vote 1 down vote accepted

Try changing:

'rewrite' => false,

in $args array to:

'rewrite' => array(
     'slug' => 'posttwo',
     'with_front' => false,
     'pages' => false
 ),

It should do the trick If I understood Your question correctly.

share|improve this answer
That'll work :) Thanks. – Angelo A Feb 18 at 15:34
I'm glad I could help. – Marcin Bobowski Feb 18 at 20:00

This has worked for me before: http://wordpress.org/extend/plugins/custom-post-type-permalinks/

share|improve this answer
Link only answers are discouraged. If something happens to that link this answer becomes useless. – s_ha_dum Feb 18 at 14:58
I dont think its a ready plugin related question. – Marcin Bobowski Feb 18 at 14:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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