I have two authors pages, one displays about 5 posts. Then I'm trying to setup another page that will be all of their posts. I have created a template called moreauthorposts.php and I'm trying to pass the author variable to this page. Problem is if i pass domain.com/more-author-posts?author=johndoe it gets stripped out. How can I retrieve this value? Is this even possible in wordpress? I know WP Rewrite is jacking my URL structure somehow I'm just not sure.

I've tried:


and tried reading this but didn't have any luck:




1 Answer 1


I'm almost sure that author is built-in, so use something like author_more. You will need to add that var to query_vars first. Example:

// add `author_more` to query vars
add_filter( 'init', 'add_author_more_query_var' );
function add_author_more_query_var()
    global $wp;
    $wp->add_query_var( 'author_more' );

Then on your more-author-posts.php template call it like this:

if ( get_query_var( 'author_more' ) )
    // do your stuff


This works in the following URl example/use case:


But if you want to use this as fancy URl, you need to add a rewrite rule:

function add_author_more_rewrite_rule()

Now you can use it like this

  • Ok so I added the query vars into the functions.php. Then added the other code to my more author posts. What would be the correct URL structure to pass these through? I know that paged uses the format of /page/2 but doing more-author-posts/more_author/johndoe doesnt' seem to be working? Jan 31, 2011 at 20:03
  • i updated the answer
    – Bainternet
    Jan 31, 2011 at 20:32
  • Problem is im not trying to pass the vars to index.php. Im trying to pass them to the custom template I have developed since it looks completely different from index. So if I pass values to moreauthor.php?author_more=johndoe .. that doesnt seem to work. Doing something wrong here? Jan 31, 2011 at 20:46
  • @בניית אתרים looks like a very clear answer! @codeisforeva You shouldn't be calling the template file directly, should you? index.php is just the root file of wordpress, every rewrite rule should go through there. Jan 31, 2011 at 22:20
  • 1
    @codeisforeva: The index.php in the rewrite rule is the index.php in the root directory of WordPress, not the index.php in your template file. You can still choose which template should be displayed, by hooking into the template_include filter.
    – Jan Fabry
    Feb 7, 2011 at 17:29

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.