1

I have a custom post type called "number" and I would like to achieve URL's for it's "posts" to be the following http://website.com/post-name instead of http://website.com/number/post-name.

I tried to set the 'rewrite' parameter in register_post_type to: 'rewrite' => array( 'slug' => '', 'with_front' => false ), but it didn't worked. Even if I saved my permalinks settings to flush it. (I have my permalinks set to Day and name - /%year%/%monthnum%/%day%/%postname%/)

Do you have any ideas how to achieve it? I am doing a transfer of one website to WP and I would like to keep the current URL structure, so it will be safe for Google as well.

Thank you in advance for any tips.

1
  • Its advised not to have something before the post name mainly because it messes with how WP handles pages. Aug 26, 2011 at 15:55

3 Answers 3

1

You could use a rewrite rule in your .htaccess file to remove number from the link.

You'll need something along the lines of:

RewriteRule ^number/(.+)$ $1 [R=301,L]
1

Here's a plugin that will help you.

http://plugins.trac.wordpress.org/browser/custom-post-permalinks/tags/1.1.4

Install it, go to Settings > Permalinks and modify the field corresponding to the CPT.

0

do you have update the permalinks after your activation of your code? Alternate you can refresh the permalinks via source in your functions with the WP function flush_rewrite_rules().

You can also read this question and answer from here.

1
  • That will not help the above issue. Custom post type permalinks are set up to display as post-type*/*post-name even with_front set to false.
    – Alex Older
    Aug 30, 2011 at 8:19

Your Answer

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

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