Rewrite the base-url for single posts

I want to append the URL when viewing a single post.
For example when im on a post I want the url to be something like: example.com/mypage/mypage/single-post-article

The default url is example.com/single-post-article

Read More

I did not find something here on WPSE or the goooglz, but I have read about wp-rewrite and tried add_post_type_support to the post but no luck!

add_post_type_support( 'post', array(
   'rewrite' => array('slug' => '/bla/bla/')
));

Do I need to use wp_rewrite?

Update

I did get this to work by run register_post_type on the post_type “post” again. But is this the best way?

  register_post_type( 'post', array(
        'public'  => true,
        '_builtin' => false, 
        '_edit_link' => 'post.php?post=%d', 
        'capability_type' => 'post',
        'map_meta_cap' => true,
        'hierarchical' => false,
        'rewrite' => array( 'slug' => '/mypage/mypage' ),
        'query_var' => false,
        'pages'     => false,
        'supports' => array( 
            'title', 
            'editor',
            'author', 
            'thumbnail', 
            'excerpt', 
            'revisions
        ),
));

Related posts

Leave a Reply

2 comments

  1. Go to your Settings > Permalinks page and set your permalinks to:

    /mypage/mypage/%postname%/
    

    If you don’t want categories to append /mypage/mypage, you can change their permastruct:

    function wpa85084_category_permastruct(){
        global $wp_rewrite;
        $wp_rewrite->extra_permastructs['category']['struct'] = '/category/%category%';
    }
    add_action( 'init', 'wpa85084_category_permastruct' );