Last active
July 22, 2020 14:11
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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