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' );

1 Answer
1

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.

Leave a Reply

Your email address will not be published. Required fields are marked *