• The default author url for author archives is the user_nicename, which is essentially a version of the username. I don’t want it to display that – I want it to use the display name instead.

    Any ideas about how to change that?

Viewing 15 replies - 1 through 15 (of 15 total)
  • Of course! Don’t. Nice names are there for a reason; there are plenty of characters (blank space, apostrophe, extended ASCII characters, and non-ASCII characters) that are illegal in URLs. You could URL-encode them to make them legal, but it would make your pretty URLs quite messy. If you want to show something like:

    yourblog.com/author/Strange Attractor/

    it will have to be rendered as

    yourblog.com/author/Strange%20Attractor/

    If you happen to have an author whose name contains extended ASCII or non-ASCII characters, it’s going to get even uglier. For example, this:

    yourblog.com/author/Fran?ois Rabelais/

    would be rendered as

    yourblog.com/author/Fran%C3%A7ois%20Rabelais/

    Do you really love aggravation that much? :)

    Thread Starter StrangeAttractor

    (@strangeattractor)

    Well, actually, it would be ok if I could set up something to strip out the spaces and make it a nicename.

    What I really want is a nicename based on the display_name rather than the username.

    I don’t want the usernames to be part of the URL, partly for security, and partly because the admin username(s) are not similar to the display names on the site.

    What I really want is a nicename based on the display_name rather than the username.

    In that case, all you need to do is to edit the nice name directly in the database…

    Thread Starter StrangeAttractor

    (@strangeattractor)

    Ah, good idea! Thanks! That would work in this case because there are only a few of the nicenames I want to change.

    But I would still like to know if there’s one specific piece of code that can be changed to force nicenames to be based on the display name.

    But I guess that also creates the issue of nicenames possibly not being unique — what happens if they are not?

    Try it out and say me whether the world still exists ?? . Here is the code you have to change to use only the display name (for WP Version 2.6) – make a backup first:

    /wp-includes/author-template.php about l. 416
    replace

    if ( '' == $author_nicename ) {
    			$user = get_userdata($author_id);
    			if ( !empty($user->user_nicename) )
    				$author_nicename = $user->user_nicename;
    		}
    		$link = str_replace('%author%', $author_nicename, $link);

    with

    $user = get_userdata($author_id);
    
    		$link = str_replace('%author%', $user->display_name, $link);

    /wp-includes/link-template.php about l. 95
    replace
    $author = $authordata->author_nicename;

    with
    $author = $authordata->display_name;

    /wp-includes/query.php about l. 1235
    replace
    $q['author'] = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$q['author_name']."'");

    with
    $q['author'] = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE display_name='".$q['author_name']."'");

    /wp-includes/general-template.php about l. 211
    replace
    $title = $wpdb->get_var($wpdb->prepare("SELECT display_name FROM $wpdb->users WHERE user_nicename = %s", $author_name));

    with
    $title = $wpdb->get_var($wpdb->prepare("SELECT display_name FROM $wpdb->users WHERE display_name = %s", $author_name));

    Could anyone pack this into a plugin? It would be useful if you also can change user_nicename manually directly in wordpress’ backend. So, my idea for a new plugin! ??

    Viele Grü?e aus Germany and sorry for my b?d English!

    Hi acrylschaf,
    Thanks for your suggestion. It looks very ingeniuos. I have tried your solution using nickname instead of display_name. Nickname is a bit less risky than display_name.

    Guess what … I’ve got it working that the link indeed DOES show the nickname. However, I am getting an 404 error message ‘link not found’. I have updated the permalink structure by clicking ‘save’ so this is not the issue … any idea why it doesn’t work? Everything looks so close to being successful … ??

    Yes a plugin for updating the user nicename would be nice as well. I’m also struggling to get the author archives to point to a sanitized nickname or perhaps have a plugin that lets you edit the author nicename directly. /author/jonathandoe891156 is not exactly a very nice author url IMHO.

    Though the title of the wp-hackers thread is a bit misleading, a pertinent thread. Need to read through both threads:
    https://comox.textdrive.com/pipermail/wp-hackers/2008-October/022027.html:
    https://comox.textdrive.com/pipermail/wp-hackers/2008-October/022044.html

    Hi all,

    is there any way i can make the author url like https://www.example.com/review/author/%5BUSER_ID%5D instead of using user_nicename or display_name??

    the reason i want to do this is because authors in my site can change their user_nicename( nickname inside the site), so i want to rely on the ID instead of the user_nicename that can change anytime..

    Thx you.

    Though the title of the wp-hackers thread is a bit misleading, a pertinent thread. Need to read through both threads:
    https://comox.textdrive.com/pipermail/wp-hackers/2008-October/022027.html:
    https://comox.textdrive.com/pipermail/wp-hackers/2008-October/022044.html

    Is there any other way to change the user_nicename than changing it in the database directly?

    Worked well – changed the user_nicename value in the users table in the database. I used a dash to avoid the space turning into %20.
    I can’t figure out why we get to choose a preferred screen name but the author name defaults to our login username.

    tigtog

    (@tigtoggmailcom)

    Thanks to Anonymous – your solution worked just fine.

    Now have to go and sort out the same thing on a few client sites, as I hadn’t noticed that pretty permalinks let the whole world know your login name. Grrr.

    Hi All,

    is there any way i can make the author url like https://www.myblog.com/author_name instead https://www.myblog.com/author/author_name

    Please help Me…!!

    Thnx..

    I have the same question as Sabin_metric. I’d really like to get rid of the “author” and just have domain.com/username. Anyone have any ideas?

    found the answer to my question here https://crrrg.com/removing-the-author-base-in-wordpress/

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘How do I change author permalink from username to display_name?’ is closed to new replies.