WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. haxxxton
    Member
    Posted 2 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 :)

    haxxxton

  2. keesiemeijer
    moderator
    Posted 2 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
    Member
    Posted 2 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
    Member
    Posted 2 years ago #

    resolved

Topic Closed

This topic has been closed to new replies.

About this Topic