Skip to content

Instantly share code, notes, and snippets.

@laurelstreng
Last active July 22, 2020 14:11
Show Gist options
  • Save laurelstreng/9d4bec3cf6dbe8d9cd0c639d25b4d462 to your computer and use it in GitHub Desktop.
Save laurelstreng/9d4bec3cf6dbe8d9cd0c639d25b4d462 to your computer and use it in GitHub Desktop.
If using the Wordpress author template to show user posts, change the main query via the pre_get_posts filter hook to show all types of posts by the author.
<?php
function lstreng_author_any_post_types $query ) {
// apply changes only for author archive page
if ( ! is_author() || ! $query->is_main_query() )
return;
$query->set('post_type', 'any');
}
add_action( 'pre_get_posts', 'lstreng_author_any_post_types' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment