I setup a custom post type for my portfolio projects. The main URL for this is located at /projects/
Now I’ve also setup my blog posts permalink to /articles/*/
for the permalink structure. This means when I go to view a portfolio project the URL changes to /articles/projects/project-name/
I know there must be a way to rewrite permalinks only for my projects custom post type. But I’m unfamiliar with the syntax in declaring the URL slug – would appreciate any help I can get!
When you register the custom post type, you have to specify that the rewrite rule shouldn’t be prepended with the existing URL structure.
In short, this means that this line in your
register_post_type
call:should turn into this:
For more info, check out the
rewrite
argument from the codex entry onregister_post_type
edit: just make sure that, after updating the code, you flush the rewrite rules by visiting Settings > Permalinks. Otherwise you’ll still see the old links.
I had this problem literally 3 days ago, then I stumbled across a series over at wp.tutsplus.com. I swapped my own code out to accommodate your question better, but this is what I ended up with after following the series. Also, keep in mind that this is untested.
Theoretically, you could swap out whatever you want in the URL stored in the
$projects_structure
variable, what is there is just what I ended up using.Good luck, and as always – make sure to come back and let us know how it worked out! 🙂