Changing author base url slug in WordPress

No comments
By default, websites developed on WordPress CMS have author slug as 'author' and followed by author user name for example:

And if you want to change the author base url slug that is 'author' with some other words like member or something else then this tutorial is right for you.

To change the url slug follow below steps:

  • Locate functions.php file (You could find it in the root folder of your current active theme).
  • Open functions.php file in any text editor of your choice for example notepad++.
  • Scroll down to bottom of functions.php file and then put below code in it and save.
 function change_author_url()   
   global $wp_rewrite;   
   $wp_rewrite->author_base = 'member';   
   $wp_rewrite->author_structure = '/' . $wp_rewrite->author_base. '/%author%';   

In above code, i have renamed 'author' slug with 'member'. You can change it as per your requirement.  $wp_rewrite global variable is an instance of WP_Rewrite class. This class is used to managing the rewrite rule that allows you create fancy URL. Note that the above code is not going to change the default template for author, it will still use author.php.

No comments :

Post a Comment