The title may be a little confusing, I don’t know how to word it to be short.
Right now my permalink structure is /%post_id%/%postname%
so the final URL is /post_type/%post_id%/%postname%
.
When I go to domain.com/post_id
then it redirects to domain.com/post_type/%post_id%/%postname%
but when I got to domain.com/post_type/post_id
it doesn’t redirect but shows the correct post.
I’m not sure how to make it work the way the default redirect works.
I used the following plugin lately:
https://github.com/kasparsd/numeric-shortlinks
to get post ID based shortlinks, like
http://domain.com/123
. That worked very well for me, with a couple of custom post types too.On a sidenote, I’m not sure about your permalink structure, especially because
%post_id%
and%postname%
are both uniquely referring to the same post, but on the other hand you might have a good reason for choosing the structure exactly like that.In reference to Matthew’s comment i used the following in my
register_post_type()
call in above mentioned project:It’s just the rewrite part and of course you have to replace
%post_type%
accordingly – I also should mention that the settings for the permalinks would be set to just%postname%
.