For a user with wiki-update permission only, I want to list their wiki articles in the author archive page. Currently, it comes back with "NOT FOUND Apologies, but ...".

I am using the Twenty-ten child theme and created a custom loop-wiki.php but now have a block about how to proceed. Any ideas? Anyone? I've searched and found similar type discussion but nothing stands out.



1 Answer 1


Author archives default to searching for posts of the post type post. You could override this with wiki like so;

function wpse_11210_set_wiki_for_author( $query ) {
    if ( $query->is_main_query() && $query->is_author() )
        $query->set( 'post_type', 'wiki' );

add_action( 'pre_get_posts', 'wpse_11210_set_wiki_for_author' );

Drop it in your a plugin or your theme's functions.php (if the file doesn't exist, create it).

  • Hey there TheDeadMedic, Tried your advice, it worked, all too well! Thank you immensely! Now, if I can insert a test to discern between wiki-editor vs post author, I'll be "cook'n with gas!" Thanks again for your expertise!
    – Stevarino
    Commented Apr 2, 2011 at 17:12
  • Sorry, not sure what you mean - do you want to check if the author (or the current user) has a certain role or capability? Commented Apr 4, 2011 at 15:29
  • I think they want only the query to grab the original author and not the editors so if I create a wiki article then my author page shows that but if I edit another person wiki article then it does not show in my author page. although I always thought a wiki was public contribution and that no one owns it. Commented May 18, 2011 at 5:32
  • @TheDeadMedic what do you mean when you say "run once"? In the remove_action( 'pre_get_posts', '__set_wiki_for_author' ); Thanks a lot!!!
    – Philip
    Commented Dec 10, 2011 at 9:26
  • If we didn't remove the action after the first call, it would apply to every successive WP_Query call (which would meddle with a theme or plugin's own query). In WordPress 3.3, you can simply use is_main_query() to ensure it only runs for the request. Commented Dec 11, 2011 at 17:31

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.