Skip to content

Instantly share code, notes, and snippets.

@Kevinlearynet
Created December 5, 2012 15:45
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Kevinlearynet/4216718 to your computer and use it in GitHub Desktop.
Add custom post types to author archives in WordPress
/**
* Add Custom Post Types to Author Archives
*/
function post_types_author_archives($query) {
// Add 'videos' post type to author archives
if ( $query->is_author )
$query->set( 'post_type', array('videos', 'post') );
// Remove the action after it's run
remove_action( 'pre_get_posts', 'post_types_author_archives' );
}
add_action( 'pre_get_posts', 'post_types_author_archives' );
@wpexplorer
Copy link

No need to use remove_action here ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment