WordPress.org

Support

Support » Plugins and Hacks » Posts By Author URL Modification

Posts By Author URL Modification

  • I’m using the the_author_posts_link template tag. What I need to do is modify the actual URL; right now, it’s using the username, eg. myblog.com/author/admin but I want myblog.com/admin, or even better, myblog.com/authornickname.

    Is there a plugin out there that can handle this? If not, can someone point me towards how I would write this? I’ve done a lot of PHP/MySQL before…

Viewing 2 replies - 1 through 2 (of 2 total)
  • Setting urls from site/author/authorname to site/authorname is not a PHP/MySQL thing. It’s a .htaccess/mod_rewrite thing affecting your custom permalinks. The only way I imagine doing this is to add lines to your .htaccess, for example:

    RewriteRule ^(admin)/?$ /index.php?author_name=$1 [QSA,L]

    You would have to add one for each author you want to link to in this way. This is because pattern matching performed on custom urls take a non-declared top-level directory name (i.e. /admin) to be a Page, and nothing else. Modifying this action (as well as switching to nickname) would require changes to the WP core.

    Finally, to create a link on a post for this, you can combine a couple template tags:

    <a href="<?php bloginfo('home'); ?>/<?php the_author_login(); ?>"><?php the_author(); ?></a>

    Will this work beyond the first page, i.e. /author-name/2/ ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Posts By Author URL Modification’ is closed to new replies.
Skip to toolbar