1

I'm trying to build a new WordPress theme using register_post_type to create a custom post type called listings.

I would like each listing to have the following permalink structure:

http://www.mysite.com/%author%/listing-title

I'm not quite sure how to achieve this with the CPT controls listed in the Codex. Previously, I have a achieved a similar effect by creating a custom structure in Permalink Settings:

/%author%/%postname%/

It has been suggested on the main forum that I use wp_rewrite, but wp_rewrite only seems to deal with incoming requests and does not change the way CPT posts are created.

To illustrate further with an image, I want to change the /listings/ part of the permalink URL to the post author's name. See image below.

alt text

3

My plugin Custom Post Permalinks allows you to set permalink structures for custom post types and it supports post authors as part of a permastruct. However, while my plugin will enable you to set up that structure, I don't suggest using that structure. That structure will essentially make WordPress interpret all top-level pages as 404 errors (and second level pages, I think). You should be fine if you add the post type to anchor the beginning of the structure like this:

/%post_type%/%author%/%postname%/
  • Cool plugin, works great! – jnthnclrk Oct 22 '10 at 12:31
  • I followed your advice and accepted the need to maintain the initial /%post_type%/ section. But am now thinking it would be nice to add a /blog/ section to my non-custom post types for consistency. – jnthnclrk Oct 22 '10 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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