I am currently using this code:

function change_author_permalinks() {
    global $wp_rewrite;
    $wp_rewrite->author_base="connect/member";
}
add_action('init','change_author_permalinks');

but my current front set on my blog is:

share

So the above generates a URL like so:

http://example.com/share/connect/member/john-smith

But I don’t want /share/ as part of this author URL. I cannot remove the /share/ front as it is needed for other parts of the site.

How do I set the author URL to not use front?

1 Answer
1

This is the best solution I have come up with but I welcome better ways:

function change_author_permalinks() {
    global $wp_rewrite;
    $wp_rewrite->author_base="connect/member";
    $wp_rewrite->author_structure = "https://wordpress.stackexchange.com/" . $wp_rewrite->author_base . '/%author%';
    add_rewrite_rule('connect/member/([^/]+)/?$', 'index.php?author_name=$matches[1]', 'top');
}
add_action('init','change_author_permalinks');

Leave a Reply

Your email address will not be published. Required fields are marked *