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 reviewed all related questions but none tackle this exactly so I'm posting the question in hopes the pro's know how to handle this. I would like to change the author slug to remove the term /author/ completely like this;

currently example.com/author/username

want example.com/username

Moreover I'd like all posts related to an author to look like:

example.com/username/post-title

URl strucutres would resemble a.) either wpmu or b.) cpt without actually building either.

To add more context. I'm building a multi author blog where users have independent pages (author pages) that they can build, post, and share. All posts created by all authors will be included in the main loop (for now).

What's my best case scenario and worse case scenario to achieve this?

share|improve this question
1  
That's because the rewrite rules implementing this could cause permalink clashes,and they'd be problematic rules as they would match the majrotiy of things, and it's not a trivial thing to ask for at all. –  Tom J Nowell Oct 4 '12 at 18:35
add comment

2 Answers 2

Just an idea: Use a MU installation and give the blog names the names of the authors (use Sub-directories). This way you should get much closer to what you want to achieve with on board stuff.

This means that you'll get your author names appended to the original domain and when you go there, you'll see their blog pages = author posts.

http://example.com - main domain
http://example.com/hans

This solution would avoid any sort of programming.

share|improve this answer
add comment

One way to achieve this (and you have to be willing and able to hack WP) is the following:

Part 1 - after an author posts a new post, you explicitly change the post GUID in the database. Here is a crude example/outline:

$wpdb->update( 
        $table_name, 
        array(                          
            'guid' => (whatever url you want)
        ),
        array( 'id' =>  (post ID))
    );
  • $table_name is the table name for the specific author (e.g. 'wp_12_posts' for the 12th blog in your network).
  • 'guid' is where you enter the URL you want (example.com/username/post-title)
  • 'id' is the ID of the post created by the author

This changes the GUID of the post in the DB - now comes the interesting part.

Part 2 - add/edit index.php in your theme to handle your custom URLs. Here's an outline:

//construct the complete URL of the request 
    $guid = 'http://' . get_current_site()->domain . $_SERVER["REQUEST_URI"];
    //check if DB contains a row with this guid
    $post = $wpdb->get_row("SELECT * FROM " . $table_name . " WHERE guid = '" . $guid . "'");

basically what you are doing here is looking for the GUID you explicitly set earlier before WP handles things the 'usual' way. If $post is not empty you can now take it from there.

I am working on a complete post outlining this solution as we implemented it at Litefort for a service we are creating, check out developers.litefort.com for more.

share|improve this answer
1  
The GUID is not an URL, and it should never be used as one. It is an identifier that stays the same even after you moved the blog to another domain. –  toscho Oct 4 '12 at 22:03
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.