Created
October 7, 2015 00:07
-
-
Save riceguitar/51cca760d4fb6c8efaac to your computer and use it in GitHub Desktop.
For @johnp
This file contains hidden or 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
// Change Author URL Slug | |
add_filter( 'query_vars', 'wpleet_rewrite_add_var' ); | |
function wpleet_rewrite_add_var( $vars ) | |
{ | |
$vars[] = 'user'; | |
return $vars; | |
} | |
add_rewrite_tag( '%user%', '([^&]+)' ); | |
add_rewrite_rule( | |
'^user/([^/]*)/?', | |
'index.php?user=$matches[1]', | |
'top' | |
); | |
add_action( 'template_redirect', 'wpleet_rewrite_catch' ); | |
function wpleet_rewrite_catch() | |
{ | |
global $wp_query; | |
if ( array_key_exists( 'user', $wp_query->query_vars ) ) { | |
include (TEMPLATEPATH . '/user-profile.php'); | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@j2trumpet