Created
August 22, 2012 09:59
-
-
Save mattyza/3424115 to your computer and use it in GitHub Desktop.
Modify the "/author" rewrite rule in WordPress to read "/profile" (permalinks refresh required).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
Here's probably a short version http://www.wprecipes.com/how-to-change-author-url-base-on-your-wordpress-site