How Can I customize author slug in Wilcity?

In WordPress, the author page link will follow this instruction:

https://website.com/ + author + yourusername

For example https://wilcity.com/author/admin

Sometimes, you want to rename author to another word. Let’s an instance, I want to replace author with thelister, How can I do that?

  1. Log into your site account
  2. Activate Wilcity Child
  3. Put the following code to functions.php of Child Theme: Appearance -> Editor -> functions.php
    add_action('init', function(){
    	global $wp_rewrite;
    	$author_slug = 'thelister'; // change slug name
    	$wp_rewrite->author_base = $author_slug;
    });
    
    add_action('init', function(){
    	add_rewrite_rule('^thelister/([^/]+)/([^/]+)/?$', 'index.php?author_name=$matches[1]&mode=$matches[2]', 'top');
    }, 10, 0);
    
    add_filter('wilcity/filter_author_mode', function(){
    	return 'thelister';
    });
    
  4. Finally, click on Settings -> Permalinks -> Re-save Post Name. Now https://wilcity.com/author/admin will be changed to https://wilcity.com/thelister/admin

Leave A Comment?