• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

WP Thinker

The WordPress Playground

  • Snippets
  • Best
  • Guides
  • Reviews
Home / Code Snippets

February 28, 2021 Jayan

Change WordPress Author Slug

WordPress by default creates an author profile for every user publishing content on your website. This is a great way to organize articles and other types of data posted by separate users in a cleaner, better manner. But, in some cases, you may need to make changes to the location where the posts and author information is listed. Everyone may not like seeing it under the /author/ section. In that case, this code snippet will be helpful. You can change the default “author” keyword in your WordPress author page URL to whatever you want using the following code snippet.

For example, you can change site.com/author/john-doe/ to site.com/profile/john-doe/.

Usage

  • If you have a separate login/registration system using plugins such as Ultimate Member that provide separate author profile sections. So, in order to avoid multiple sections for the same author, you might wanna remove the default author section.
  • Just to move the current default URL to something better that matches the workflow and features of your website.
  • To shorten the URLs with something such as a single letter like /u/ for some reason.

Code

// Change Author Slug
add_action('init', 'wpt_change_author_base');
function wpt_change_author_base() {
    global $wp_rewrite;
    $author_slug = 'profile'; // replace "profile" with anything
    $wp_rewrite->author_base = $author_slug;
}

Explanation

  1. A comment to identify the function from other code blocks.
  2. Using the add_action function, we hook our newly created function wpt_change_author_base to the init to load it right after WordPress has finished loading. (You can also add this line at the very bottom after defining the function).
  3. We define the function wpt_change_author_base.
  4. Declaring the global variable $wp_rewrite (the instance of WP_Rewrite class) so that we can access the author_base from it.
  5. Creating a variable $author_slug and assigning it a value we want to use for our author slug instead of the default.
  6. Finally, we assign the value of our $author_slug variable to the author_base.
  7. And close the function.

Primary Sidebar

Related Articles

Footer

WPThinker-White-Logo

Website

  • About Us
  • Advertise
  • Write for Us
  • Contact Us

Policies

  • Privacy Policy
  • Terms and Conditions
  • Facebook
  • Twitter
  • Pinterest
Copyright © 2025 · WP Thinker
This website uses cookies to serve you better. By continuing to use this website, you agree to our cookie and Privacy Policy.