How To Change the Author URL Slug in wordpress


Are you looking for a way to change the author URL slug? This snippet will change the default slug, mysite.com/author/name, to mysite.com/profile/name. However, you can change this to anything that you would like.
Instructions:
  1. Add this code to your theme’s functions.php file or in site-specific plugin.
  2. Change profile in line 4 to any name you would like.
add_action('init', 'cng_author_base');
function cng_author_base() {
    global $wp_rewrite;
    $author_slug = 'profile'; // change slug name
    $wp_rewrite->author_base = $author_slug;
}
Note: If changes is not reflecting after adding the code, you can check after updating permalink setting from back-end.

No comments:

Post a Comment