WordPress.org

Ready to get started?Download WordPress

Forums

How to change author base without front (3 posts)

  1. Scott Cariss
    Member
    Posted 2 years ago #

    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?

  2. jackie.shaffer
    Member
    Posted 2 years ago #

    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');
  3. Thomas Maier
    Member
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic