1

I have to re-register WordPress default post type to change the post slug to "blog", changing permalink structure was not worked for me as it rewrite custom post types slugs also. So I used below code in my function.php:

function my_new_default_post_type() {
register_post_type( 'post', array(
    'labels' => array(
        'name_admin_bar' => _x( 'Post', 'add new on admin bar' ),
    ),
    'public'  => true,
    '_builtin' => false,
    '_edit_link' => 'post.php?post=%d',
    'capability_type' => 'post',
    'map_meta_cap' => true,
    'hierarchical' => false,
    'rewrite' => array( 'slug' => 'blog' ),
    'query_var' => false,
    'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
) );
flush_rewrite_rules();
}
add_action( 'init', 'my_new_default_post_type', 1 );

It worked fine and satisfied my need. But the issue is now it showing "post" item twice in the admin bar. Why is this happening?

1 Answer 1

0

you may try to de-register/unset default post type and register post type with your requirements.

if ( ! function_exists( 'unset_default_post' ) ) :
function unset_default_post( ) {
    global $wp_post_types;
    $post_type = 'post';
    if ( isset( $wp_post_types[ $post_type ] ) ) {
        unset( $wp_post_types[ $post_type ] );
        return true;
    }
    return false;
}
endif;
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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