Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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' );
Copy link

wpexplorer commented Feb 14, 2019

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