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.
You could use a rewrite rule in your .htaccess file to remove number from the link.
You’ll need something along the lines of:
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.
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.