Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alexanderdejong/e0aae4936d19779b17a3b0769c37ba29 to your computer and use it in GitHub Desktop.
Save alexanderdejong/e0aae4936d19779b17a3b0769c37ba29 to your computer and use it in GitHub Desktop.
Modify the "/author" rewrite rule in WordPress to read "/profile" (permalinks refresh required).
<?php
/**
* Plugin Name: Add "/profile" URL rewrite rule.
* Version: 1.0.0
* Author: Matty
* Description: Add a rewrite rule to redirect "/profile" URLs to the appropriate author archive screen.
*/
new Matty_Profile_Rewrite();
class Matty_Profile_Rewrite {
public function __construct () {
add_filter( 'author_rewrite_rules', array( 'Matty_Profile_Rewrite', 'modify_author_base' ) );
} // End __construct()
public function modify_author_base ( $rules ) {
$new_rules = array();
foreach ( (array)$rules as $k => $v ) {
$key = str_replace( 'author/', 'profile/', $k );
$new_rules[$key] = $v;
}
$rules = $new_rules;
return $rules;
} // End modify_author_base()
} // End Class
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment