WordPress Custom Author Permalink

DSDalton SuttonMarch 19, 2024
View AllHide Notes

How To Install

  1. Open your WordPress theme's functions.php file or a plugin's PHP file.
  2. Copy and paste the provided PHP snippet into the PHP file.
  3. Save the file.
  4. Go to Settings > Permalinks and click "Save" — this flushes the rewrite rules.
  5. Adjust as needed.
  6. In this example, /author/ is rewritten to /members/

// rename route /author/ to /members/
function daltonsutton_rename_author_to_members() {
    global $wp_rewrite;
    $wp_rewrite->author_base = 'members';
    $wp_rewrite->author_structure = '/' . $wp_rewrite->author_base. '/%author%';
add_action('init', 'daltonsutton_rename_author_to_members');

// rewrite route /author/ to /members/
function daltonsutton_rewrite_author_to_members() {
    add_rewrite_rule('^members/([^/]+)/?', 'index.php?author_name=$matches[1]', 'top');
add_action('init', 'daltonsutton_rewrite_author_to_members');