Including post_type = ‘wiki’ in author archives

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