Skip to content

Instantly share code, notes, and snippets.

@riceguitar
Created October 7, 2015 00:07
Show Gist options
  • Save riceguitar/51cca760d4fb6c8efaac to your computer and use it in GitHub Desktop.
Save riceguitar/51cca760d4fb6c8efaac to your computer and use it in GitHub Desktop.
For @johnp
// 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;
}
}
@riceguitar
Copy link
Author

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