By default WordPress author slug is – /author/[author_display_name]
.
How about if we need to change this to something else? Perhaps your site is not in English, and you want author slug in your language?
This is very easily controllable with author_base
property of WP_Rewrite
class.
function careless_rewrite_pagination_slug() {
global $wp_rewrite;
$wp_rewrite->author_base = 'something-else';//edit something-else to whatever you want
}
add_action( 'init', 'careless_rewrite_pagination_slug' );
Code goes in the functions.php
file of your active theme.
Now, since we have changed slug/permalink, we need to clear WordPress permalink cache for this change to start working. We can do that using flush_rules
property of WP_Rewrite
class. But there is no point to call it every time, when our code runs. Instead, we will clear this manually from WP Admin. Head to WP Admin > Settings > Permalinks
and click on the Save Changes
. You don’t really need to make any change – just a button click. That will clear permalink cache, and our new search slug will start working.