Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

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
        ),
));
share|improve this question

2 Answers 2

up vote 8 down vote accepted
+50

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' );
share|improve this answer
    
Thats awesome, thanks! –  Pontus Abrahamsson Feb 11 '13 at 8:29
    
one remark regarding Milo answer, i tryed it, it work's but how about the author, tags ...etc the permalink structure affect all the website not only the posts, so how to restrict it to only posts ? –  user48881 Mar 13 at 7:42

Did you try flushing your rewrite rules after you defined them?

flush_rewrite_rules();
share|improve this answer
    
You should always add a caveat with this that it should only be done once, so doing it via code is dangerous. Personally, I always flush my rewrites by updating the permalinks on the permalinks settings page. –  Matthew Boynes Feb 14 '13 at 19:27

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.