Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
I also have this question, though in my case, the /%list% won't always be a custom post type. Did you ever figure this out? –  Ryan Oct 16 '12 at 7:31
add comment

3 Answers

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

RewriteRule ^members/%author%/(.*)$ domain.com/%custom-post-type%/$1

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%

RewriteRule ^members/(.*)/(.*)$ domain.com/members/$1/%custom-post-type%/$2

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

share|improve this answer
add comment

add_rewrite_rule() should be the answer http://codex.wordpress.org/Rewrite_API/add_rewrite_rule

or you can manually filter author_rewrite_rules

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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