[Support request] Change author URL

Home Forums Support Change author URL

  • This topic has 5 replies, 2 voices, and was last updated 12 months ago by David.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1021351
    Paul

    Hello,

    I want to change the author URL from the default location to a location specified by me. I currently have a 301 in place to achieve this but would like to remove the redirect hop and have it “hard coded”.

    Please let me know if this is possible.

    Thanks Paul

    #1021383
    David
    Staff
    Customer Support
    #1023481
    Paul

    Thanks David – how would I adapt this for a multi author site. I don’t have a huge amount of authors so do I just repeat the function with each author specified? If so could you provide the correct syntax

    #1023639
    David
    Staff
    Customer Support

    Little more complicated – try this instead:

    add_filter( 'author_link', 'switch_author_links', 10, 2);
    
    function switch_author_links( $url, $user_id) {
        switch($user_id) {
            case "100":
                return home_url( 'author_slug_1');
                break;
            case "200":
                return home_url( 'author_slug_2');
                break;
            case "300":
                return home_url( 'author_slug_3');
                break;
        }
        return $url;
    }

    Create a case for each author ID and return the page_slug for that author.

    Example:

    case "100":
    return home_url( 'author_slug_1');

    Author ID of 100 will have a link of mywebsite.com/author_slug_1

    You can get each Author ID by going to Users > All users and hovering over the number of Posts they have created, the link at the foot of the browser will include the ID.

    #1024260
    Paul

    worked a treat. Thanks.

    #1024288
    David
    Staff
    Customer Support

    Awesome – glad to be of help

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.