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

I have a wordpress website with bunch of posts. My problem is that I need to change the URLs from




The "specialword" is what I need to add in front of those post names, but ONLY for the post type - posts.

Can someone help me?

I need this badly, mostly because of the SEO purposes so I can keep the URLs from the previous website that wasn't done in wordpress.

Thank you! Slavisa

share|improve this question

You can do it from Settings > Permalinks.

Select the Custom Structure radio button, and put this in the text field next to it:



share|improve this answer
I know that, but I need this setting applied ONLY to post type posts, not all types of posts (pages, custom post types, etc) – SlavisaPerisic Sep 27 '12 at 7:23
Have you tried it? – Rutwick Gangurde Sep 27 '12 at 7:53
Of course I have, and it works fine for posts and pages, but the custom post type pages have the url: /myspecialword/custom-post-type/%postname% – SlavisaPerisic Oct 3 '12 at 10:19
Ohh yes... Cuz the special word gets appended after the url. I guess you might need a URL rewrite. – Rutwick Gangurde Oct 4 '12 at 5:13
Adding rewrite rule won't be sufficient in this case. If you do this, get_permalink still will be generating wrong links for such custom post type... – Krzysiek Dróżdż Jun 28 '13 at 11:20

I think the only (the easiest) solution is to change permastructs for custom post types after registering them and add your 'magic word' to permalink structure.

So set (in parmalinks settings) your permalink structure to: /my-magic-word/%postname%/ and then manually modify permastructs of your custom post types.

You can do this like so (add it to your functions.php file):

function my_init() {
    global $wp_rewrite;

    // Let's assume you register your CPT Books in here
    $args = array( 'public' => true, 'label' => 'Books' );
    register_post_type( 'book', $args );

    // after registering your CPT, you have to change it's permastruct
    $wp_rewrite->extra_permastructs['book']['struct'] = "book/%book%";  // it's without 'my-magic-word' - you should do this for every CPT that should not have 'my-magic-word' in url
add_action('init', 'my_init');

Then go to permalink settings and save them to flush rewrite rules.

PS. I think you could try to use with_front param, but I'm not sure if it will be easier (or if it even will work) than this solution.

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.