Change author permalink

The question:

The original urls for users look like /author/login/

Is it possible to replace login by user’s id?

In my dream urls should become to /users/34/ (34 is user id).


The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

you need 3 simple functions and hooks

first change the author base:

//change author/username base to users/userID
function change_author_permalinks() {
  global $wp_rewrite;
   // Change the value of the author permalink base to whatever you want here
   $wp_rewrite->author_base = 'users';


then add users to query_vars:

add_filter('query_vars', 'users_query_vars');
function users_query_vars($vars) {
    // add lid to the valid list of variables
    $new_vars = array('users');
    $vars = $new_vars + $vars;
    return $vars;

then add the new rewrite rule:

function user_rewrite_rules( $wp_rewrite ) {
  $newrules = array();
  $new_rules['users/(d*)$'] = 'index.php?author=$matches[1]';
  $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;

Now if you don’t know how to use this, just copy all of the code and paste in your theme’s functions.php file.

Method 2

You could use an htaccess rule to rewrite /users/34 to /?author=34

Method 3

I built a plugin to do this. A friend wanted to hide his author URL’s as he didn’t like the fact they were displaying his author’s usernames. I decided to go one further and allow any user to set their own URL. It redirects their old author pages.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment