Forums

Change default URL for author link (2 posts)

  1. hpatoio
    Member
    Posted 1 month ago #

    Hello.

    Author link are created this way

    http://domain.tld/author/username/

    is there a way to change it ?
    I've a blog with several authors and usernames are in the format of name.surname For privacy and SEO reason I want my author link be in the format of http://domain.tld/author/nickname/

    Where nickname is the value the user specify in his profile.

    Thanks

    --
    Simone

  2. doc4
    Member
    Posted 1 month ago #

    hpatoio,

    Not a huge fan of altering the core but have you looked at wp-includes/author-template.php starting on line 166.

    function the_author_posts_link($deprecated = '') {
    	global $authordata;
    	printf(
    		'<a href="%1$s" title="%2$s">%3$s</a>',
    		get_author_posts_url( $authordata->ID, $authordata->user_nicename ),
    		sprintf( __( 'Posts by %s' ), esc_attr( get_the_author() ) ),
    		get_the_author()
    	);
    }

    Perhaps altering "user_nicename" to "display_name" is what you are looking for. I don't have time to test this right now but seems like a good start. Of course there are several other locations this will need to be altered as well: link-template.php, query.php and general-template.php.

    Just a thought anyway.

Reply

You must log in to post.

About this Topic