The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] override wp_rewrite's $author_base for theme (4 posts)

  1. haxxxton
    Posted 4 years ago #

    Hey guys,

    I found this post here talking about changing the $author_base property in the class of wp_rewrite.

    I want to do the same thing, but I know it's bad practice to edit core files.. is there a way to override this variable in my theme's init or at runtime?

    i.e. to:

    var $author_base = 'user';

    Thanks in advance :)


  2. keesiemeijer
    Posted 4 years ago #

    Try it with this in your functions.php:

    function custom_author_base(){
    global $wp_rewrite;
    $wp_rewrite->author_base = 'user';
    add_action('init', 'custom_author_base', 0 );

    You have to re-save your permalink structure under Settings >Permalinks for this to work.

  3. haxxxton
    Posted 4 years ago #

    keesiemeijer, worked like a charm, going to be using it in a plugin i think so ill get it to flush_rewrite_rules() on plugin activation and again on deactivation to save the user having to do the permalink resaving manually :)

    appreciate it

  4. haxxxton
    Posted 4 years ago #


Topic Closed

This topic has been closed to new replies.

About this Topic