I've created a page in the dashboard called Authors, created a new template-authors.php with completely own logic. It works well, going to website.com/authors/ I see a list of all authors, specifying the URL I can get to their details, for instance: example.com/authors/?name=George. I can also switch profile pictures: example.com/authors/?name=George&pic=1, example.com/authors/?name=George&pic=2 etc (default is 1).

I'm trying for half a day get user-friendly URLs been working but can't figure out a correct way... I'd like to achieve this kind of links: example.com/authors/George and website.com/authors/George/2.

Tried even a really basic code in the functions.php, but it doesn't work:

add_rewrite_rule('^qwerty', 'index.php/authors/', 'top');

example.com/qwerty displays 404.

1 Answer 1


I'm pretty sure you have wrong "rewrite" parameter in your add_rewrite_rule call.

I'm writing it directly in here, so it can be buggy... But it should look something like this:

add_rewrite_rule('^authors/([^/]*)/([^/]*)/?','index.php?page_id=<YOUR AUTHOR PAGE ID>&my_author_name=$matches[1]&my_author_pic=$matches[2]','top');

Then you can use add_rewrite_tag (http://codex.wordpress.org/Rewrite_API/add_rewrite_tag) to add your custom query variables (my_author_name and my_author_pic).

And in your author page you should use these custom query variables.

  • It works! I had to change 'index.php/authors/?...' to 'index.php?pagename=authors&...'. Thx!
    – cold
    Jun 20, 2013 at 10:46
  • As I said your "rewrite" param was incorrect :) Jun 20, 2013 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.