how to change wordpress author slug or URL base

Every custom them has option, Managing or change wordpress author slug is common in wordpress sites. you can use our come snippet for this for change author URL base. Some times you want to change the worpdress author URL slug then you can use the following code:
You need to add code into functions.php of your wordpress theme.

how to change wordpress author slug or URL base

That will change the default yoursite.com/author/authorname to yoursite.com/author-profile/authorname.
So you can change this to user or anything that you would like.

add_action('init', 'change_wp_author_base');
function change_wp_author_base() {
global $wp_rewrite;
$author_slug = 'author-profile'; // change author slug name
$wp_rewrite->author_base = $author_slug;
}

If you are facing any issue then write to me.

change wordpress author slug
change wordpress author slug

how to show author information on each wordpress post

show author information on each wordpress post is really good habit in wordpress post. So reader will know information writer who is writing the article. Many people like this information and they really read the information about author.

how to show author information on each wordpress post

how to show author information on each wordpress post
how to show author information on each wordpress post

For showing the author information you need put following code in the functions.php file show after your post content the author information will displayed to reader.


function get_author_bio($content=''){
global $post;

$post_author_name=get_the_author_meta("display_name");
$post_author_description=get_the_author_meta("description");
$html="</pre>
<div id="about_author" class="clearfix">\n";
$html.="<img class="avatar" src="http://www.gravatar.com/avatar.php?gravatar_id=&quot;.md5(get_the_author_email()). &quot;&default=&quot;.urlencode($GLOBALS[" alt="PG" width="80" height="80" />\n";
$html.="
<div class="author_text">\n";
$html.="
<h4>Author: ".$post_author_name."</h4>
\n";
$html.= $post_author_description."\n";
$html.="</div>
</div>
<pre>
\n";
$html.="</pre>
<div class="clear"></div>
<pre>
\n";
$content .= $html;

return $content;
}

add_filter('the_content', 'get_author_bio');

Just put the above code in functions.php file. You dont need to do code in single.php file.

Remove author word from wordpress permalink

In wordpress some people wants to create the community site and they want to create uniqe url for each user. In that time you need to remove the author word from wordpress permalink. Normally when we want to see the author URL then you can see URL as follows.

Remove author word from wordpress permalink

Co-Authors Plus Remove author word from wordpress permalink
Co-Authors Plus Remove author word from wordpress permalink

http://website.com/author/username/

If you can want to change the url to following

http://website.com/username

then you just need to edit only .htaccess file. Put following line in that file

RewriteRule ^author/(.+)$ http://www.yourblog.com/$1 [R=301,L] // change yourblog to website name 

If you dont want to change the .htaccess file and still want to change the permalink structure then open the functions.php file from you wordpress theme folder.

add_filter('author_link', 'no_author_base', 1000, 2);
function no_author_base($link, $author_id) {
    $link_base = trailingslashit(get_option('home'));
    $link = preg_replace("|^{$link_base}author/|", '', $link);
    return $link_base . $link;
}
add_filter('author_rewrite_rules', 'no_author_base_rewrite_rules');
function no_author_base_rewrite_rules($author_rewrite) {
    global $wpdb;
    $author_rewrite = array();
    $authors = $wpdb->get_results("SELECT user_nicename AS nicename from $wpdb->users");
    foreach($authors as $author) {
        $author_rewrite["({$author->nicename})/page/?([0-9]+)/?$"] = 'index.php?author_name=$matches[1]&paged=$matches[2]';
        $author_rewrite["({$author->nicename})/?$"] = 'index.php?author_name=$matches[1]';
    }
    return $author_rewrite;
}