WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anybody know how to modify the url struct only for the single post page?

When I go to a post page, the url should look like: example.com/xxx/my-post. All other urls (with the exception of the single post pages) should not contain "xxx" in the url.

Customizing the permalink settings would add xxx in front of taxonomies and categories as well, so that wouldn't work for what I need.

Essentially, I want that all "post" and "events" urls co contain an extra "xxx" segment in the structure.

share|improve this question
I think that this is the best (and easiest) option: stackoverflow.com/a/15619416/2349527 :) – marsjaninzmarsa Mar 4 '15 at 4:44
up vote 2 down vote accepted

The solution is to reregister the default post type just after Wordpress, and to add a rewrite slug. Also, the _builtin param needs to be set to false.

add_action( 'init', 'my_new_default_post_type', 1 );
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' => 'post' ),
        'query_var' => false,
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
    ) );
share|improve this answer

Another method without the potential side-effects of registering a new post type is to modify the rewrite rules to remove the permalink front.

function wpa37911_permastructs(){
    global $wp_rewrite;
    $wp_rewrite->extra_permastructs['category']['struct'] = '/category/%category%';
    $wp_rewrite->extra_permastructs['post_tag']['struct'] = '/tag/%post_tag%';
add_action( 'init', 'wpa37911_permastructs' );
share|improve this answer

Your Answer


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.