Skip to content

Instantly share code, notes, and snippets.

@paulredmond
Created October 6, 2013 05:14
Show Gist options
  • Save paulredmond/6849795 to your computer and use it in GitHub Desktop.
Save paulredmond/6849795 to your computer and use it in GitHub Desktop.
Custom author rewrite urls for WordPress
<?php
// Custom author URI structure even if the site
// is configured to use a custom structure, ie: /my-prefix/%postname%/
add_filter('init', function () {
global $wp_rewrite;
$wp_rewrite->author_structure = '/' . $wp_rewrite->author_base. '/%author%';
// Only uncomment the flush_rules() method call if things are not working.
// After the rules are flushed (refresh page), this can be commented out again.
// $wp_rewrite->flush_rules();
});
@paulredmond
Copy link
Author

You can even set a custom author_base, ie:

<?php
// /member/%author%
$wp_rewrite->author_base  = 'member';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment