I am working with a client who has a directory site that allows users to create accounts, then lists of items from the directory. Right now, whenever a user creates an account, she gets a profile URL like:
domain.com/member/%author%
Which is accomplished with a simple:
$wp_rewrite->author_base = 'member';
Now, I need to allow those users the ability to create a list, which should result in this kind of a URL structure:
domain.com/member/%author%/%list%
So far, I’m creating these lists as custom post types. All of the articles and Stack Exchange posts I see on WP_Rewrite don’t cover a URL rewrite like this. Is this possible? Do you have any pointers on how this could be done?
Option 1
I assume custom post type generate a URL something like this
domain.com/%custom-post-type%/%list%
So you could write it so it looks as… since the main URL doesn’t have author before custom type you would have to do this via a function since authors are dynamic
This doesn’t specifically modify the custom post type URLs but you should be able to modify this to your need
https://gist.github.com/4336843
Option 2
or possibly if URL like this below and the custom post type doesn’t change you should be able to implement this in .htaccess and it takes the author in to account when rewriting
domain.com/members/%author%/%custom-post-type%/%list%
This has a very good explanation on rewrite URL in general
http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
Option 3
Also you can rewrite the entire custom post type URL if you are not using it anywhere else… because
register_post_type();
accept'rewrite' => array ($slug)
more info
http://shibashake.com/wordpress-theme/custom-post-type-permalinks
http://shibashake.com/wordpress-theme/custom-post-type-permalinks-part-2
add_rewrite_rule() should be the answer
http://codex.wordpress.org/Rewrite_API/add_rewrite_rule
or you can manually filter
author_rewrite_rules
I hope the following plugin will help you more:
http://wordpress.org/extend/plugins/permalink-editor/
This plugin it will rewrite the permalink as you want it without any coding knowledge.