• Would really appreciate it if anyone can help with this. I am trying to remove the /author/ slug in author pages so that instead of:
    http://www.domain.com/author/craig

    you use:
    http://www.domain.com/craig

    I have the following in functions.php:

    function set_new_author_base() {
        global $wp_rewrite;
    	$author_slug = '';
    	$wp_rewrite->author_base = $author_slug;
    }
    add_action('init', 'set_new_author_base');

    which worked in wordpress 3.2.1. However in 3.3, this function breaks all pages. Categories, posts and author pages work, but all pages return a 404. I am guessing this is because of the newly rewritten permalink engine in 3.3 but I stuck getting it to work again.

    The site is not live yet so I don’t have a link, unfortunately.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi Talbet, I am facing the same problem.

    Could you solve it?

    Thank you.

    Thread Starter talbet

    (@talbet)

    Put this snippet in functions.php in your theme directory and then refresh permalinks by navigating to yourdomain.com/wp-admin/options-permalink.php and you should be able to get it working with a compromise.

    function set_new_author_base() {
        global $wp_rewrite;
        $wp_rewrite->author_base = '';
        $wp_rewrite->page_structure = "/page/%pagename%/";
    }
    add_action('init', 'set_new_author_base');

    No guarantees that this will work but thats what I ended up doing. However, all your pages will be prepended with a /page/ slug. It seems that WP3.3+ cannot have more than one post-type that rewrites directly from the domain.

    Anyone know of a better way?

    Talbet, we have our pages links around for a while, it would be a huge work change.

    On another hand, it also is messing with the Archives by date links.

    If anyone has a better solution, I would like to know.

    Thank you anyway.

    Found this somewhere:

    add_filter('author_link', 'no_author_base', 1000, 2);
    function no_author_base($link, $author_id) {
        $link_base = trailingslashit(get_option('home'));
        $link = preg_replace("|^{$link_base}author/|", '', $link);
        return $link_base . $link;
    }

    Doesn’t seem to do anything in my site – my old /profile/… slug keeps working after replacing the filter – so provided here for comments etc.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Changing the author slug in 3.3’ is closed to new replies.