WordPress.org

Forums

Change Author slug (5 posts)

  1. eric34
    Member
    Posted 1 year ago #

    Hi !

    I would like to change the public author page from : sitename.com/author/nickname to sitename/author/ID

    Any idea how I could do that?

    Thanks !

  2. georgechr
    Member
    Posted 1 year ago #

  3. eric34
    Member
    Posted 1 year ago #

    Hi! No it doesn't.

    That may change the "base slug" but this is not the "author" I want to change but the "nickname" !

  4. georgechr
    Member
    Posted 1 year ago #

    ok :) if i find something i wrote it here!

  5. bcworkz
    Member
    Posted 1 year ago #

    Intercept the query at the 'parse_query' action. Verify that $query->is_author is true. The ID from the URL will be in the query var 'author_name'. WP hasn't yet figured out the query var is not a valid author name. Use the ID to get the actual user_nicename and set the 'author_name' to the actual nice name value.

    The result is the usual author archive page, but accessed using author's user ID. Unless you build in logic to detect the ID integer before getting the userdata, providing the normal nicename in the URL will cause an error.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.