In WordPress how do you create a custom post type with the author’s name in the slug?

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:

Read More

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

Related posts

Leave a Reply

1 comment

  1. 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%/