Take the 2-minute tour ×

I just came across this page with almost similar requirements as mine

Multiple endpoints to same page

i have to achieve same functionality but i also want to pass some parameters to the page where all these URL will be map. say example


i want to map them to same URL


along with it i also want to send some other parameters like

  1. user email
  2. user name

so that i can use them at that page for my custom logic.i know how to do it in JSP/Java where i can send them as a request parameters in POST request and can reterieve them in the final JSP

how i can achieve this is wordpress using php.my prefrences are not to use any query string.

Or is it possible like if i create URL with like


where user1 etc can be fetched from the database and we can ensure that they will be unique through the application and mapping these URLs to same end point. how can i fetch the username in my final page?

Thanks in advance

share|improve this question

3 Answers 3

up vote 1 down vote accepted

You can use the same answer as the question you referred to (I have answered it). Here's how you would change to pass the arguments:

    add_action('init', 'add_my_rule');

    function add_my_rule()
        global $wp;


Assuming 'finaldestination' stays the same always, and the pagename (slug) is 'about' (you can change both). Apply your custom template to this page, and on the template, do this:

//if you visit http://.../test/finaldestination/name/romeo, then $params will be name/romeo. You can explode this and get the value.
$params = get_query_var('args');

After you put this code in your file, just go to Settings>Permalinks and hit the save button. I haven't tried this, but have used something similar in a recent project and I'm sure it will work.

share|improve this answer
Thanks for the input basically i have a page with URL's localhost/blog/wordpress/author/admin where related author post will be shown , i have author.php page where i am using custom query based on some parameters.So all i want is that if i have an author with name "my-author" URL should be localhost/blog/wordpress/author/my-author which should map with "localhost/blog/wordpress/author/admin/"; and i can user "my-author" to query my database to fetch his posts.I am not sure how feasible it is. –  Umesh Awasthi Nov 22 '11 at 16:19
i tried your code as follows $wp->add_query_var('args'); add_rewrite_rule('author/(.*)','index.php?pagename=author&args=$matches[1]','top‌​'); and when i tried to access following URL localhost/blog/wordpress/author/my-work it giving me 404 error –  Umesh Awasthi Nov 26 '11 at 8:03
Why are you trying to write such a URL? WordPress already has the Author archive url as this. So http://localhost/blog/author/my-author always will point to the archive page for my-author. Also, One possible reason could be, author is a term reserved in WP universe. You should try with some other term instead of author. And, is your page slug author? –  Rutwick Gangurde Nov 26 '11 at 9:16
i am not sure what you mean by page slug as 'author' just being new to platform make me confused.Thing is these authors will be guest authors with no profile stored or we will not create a user account for them,all we can do is store some author name field in custom section of post and use that for fetching his/her post –  Umesh Awasthi Nov 26 '11 at 9:50
Ohh... if you're new to the platform, then you shouldn't really play around with the URLs. What you're trying to do will take a lot more than a simple URL rewrite rule! One way would be to append the meta fields key (lets say the author name) to the URL and then get the posts which have this meta key. –  Rutwick Gangurde Nov 26 '11 at 10:04

Just be sure to add a canonical URL into the header of the duplicate pages, referring to the main instance of the page ... else you'll end up with duplicate content - which is bad for SEO (only matters if these pages are public and indexed).

Also would go for the theme's author.php or permalink %author% in case it's regular WordPress users. You can access the data about like that:

$author = get_user_by('slug', $author_name);
$author_id = (int)$author->ID;
$name = $author->first_name.' '.$author->last_name;

WP Codex: get_user_by()

share|improve this answer

If your words made senses to me correctly, possible solutions are here:

For the first part, you may use WordPress Redirection plugin to satisfy your needs easily.

For the second part, you may use %author% for permalink structures. Check out codex.

share|improve this answer
Can we do this without a plugin as i am not in favour of using plugin when the things can be done with some modification. –  Umesh Awasthi Nov 21 '11 at 13:45

Your Answer


