Including post_type = ‘wiki’ in author archives

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.

Thanks!

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).

Leave a Comment