WordPress.org

Support

Support » How-To and Troubleshooting » How to change author base without front

How to change author base without front

  • 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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • This one had me stumped as well.
    After reading up on the WP_Rewrite class
    http://codex.wordpress.org/Class_Reference/WP_Rewrite

    I noticed that you will also need to set your $wp_rewrite->author_structure

    The below assumes you want your author base to look like
    http://example.com/connect/member/john-smith

    After you update your code, be sure to visit your wp-admin/options-permalink.php and click “save” to flush your rewrite rules

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

    I was just searching for exactly this code snipped and since no one else says this: Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to change author base without front’ is closed to new replies.
Skip to toolbar