Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @zhuceyouxiang88

    One way you should be able to do this is to set the Authors Website to the specific page for that Author. You can change this value in the User profile page for that author.

    Whether this works will depend on how the author URL is fetched by the theme you are using.

    Assuming you wanted to do this for ALL authors and the links matched xuzhousoft.com/author-name, you could do this (this also assume your theme uses the standard function for the posts link):

    add_filter( 'author_link', 'my_author_link', 10, 3 );
    
    function my_author_link( $link, $author_id, $author_nicename ) {
        return "https://xuzhousoft.com/{$author_nicename}";
    }

    If you just wanted to do it for this one author:

    add_filter( 'author_link', 'my_author_link', 10, 3 );
    
    function my_author_link( $link, $author_id, $author_nicename ) {
        return 'zhuliang' === $author_nicename
               ? "https://xuzhousoft.com/{$author_nicename}"
               : $link;
    }

    Note that this would replace all links to the post author archive with the new URL.

    Moderator bcworkz

    (@bcworkz)

    You can cause the author URL to be as desired, but as Jonathan alluded to, it does not mean WP will know how to process the request. As it is, WP will try to find a post or page named named “hullang” or whatever the requested author is. Not finding such a post, WP will report nothing found and return a 404 status.

    Of course you could create a post or page for every author you have, but WP will not automatically return the usual archive listing you get with /author/hullang/. The reason /author/ is part of the default permalink is so WP can distinguish author archive requests from all others. Without such an “anchor” element for authors and have it still behave the same way, you’ll need to add some extra processing for all requests. For example, perhaps the “request” filter could be used. WP will have assumed the request is for a page or post. Your added callback could see if any author exists for that presumed post. If so, rework the request query vars to make it a proper author request.

    If no author matches the request, it’s safe to do nothing and let WP do what it does.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to change the url of the author to a specific page?’ is closed to new replies.