Last active
March 30, 2018 15:34
-
-
Save adambradford/8e2fea8e63502c7f25410eefddd0642a to your computer and use it in GitHub Desktop.
Display Custom Post Type in WordPress Author Archive
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 | |
//* Add this to your functions.php file. Do NOT include the opening php tag | |
// Display Custom Post Type in Author Archive | |
function post_types_author_archives($query) { | |
if ($query->is_author) | |
// Allow 'my_custom_post_type' CPT and the default 'posts' to display in author's archive | |
$query->set( 'post_type', array('my_custom_post_type', 'posts') ); | |
remove_action( 'pre_get_posts', 'custom_post_author_archive' ); | |
} | |
add_action('pre_get_posts', 'post_types_author_archives'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment