Was trying to create author specific page with author specific URL and it was working fine,but when i created this URL did not taken in to account following 2 factors
- Author Name Conflict (similar name).
- Paging option to be added to author page (for his published posts)
here is my initial rule
function add_my_rule() {
global $wp;
$wp->add_query_var('args');
add_rewrite_rule('writer\/(.*)','index.php?pagename=writer&args=$matches[1]','top');
/*global $wp_rewrite;
$wp_rewrite->flush_rules();*/
}
add_action('init', 'add_my_rule');
This was working file for a URL say
www.myblog.com/writer/umesh-awasthi ,
but there can be more author with same name and this will create a issue.So i was planning to have Blog author URL like SO have
www.myblog.com/writer/001/umesh-awasthi
where 001
is user id which will always be unique.
second issue is with paging, as i am able to create paging on the author page but when user is clicking second page the URL is coming as
http://localhost/blog/wordpress/writer/umesh-awasthi/page/2/
so as per my URL-Rewrite rule i will get following data as parameter umesh-awasthi/page/2
which means that now my query will not work as it will expect the author name as umesh-awasthi
and will get it as umesh-awasthi/page/2
My Question is can i rewrite the rule so that i should get data in following way in three different variables
- userid
- author name
- page number (if it exits)
being new to the WP and rewrite i am not sure how i can achieve this
thanks in advance