Author posts not appearing for custom post type

I managed to resolve this issue by using pre_get_posts function and adding the custom post type to the main query.

I added the below to my functions.php file and now I get results for authors in my custom post type:

/* pre_get_posts function added to include post type blog in author loop */
  function add_cpt_author( $query ) {
    if ( !is_admin() && $query->is_author() && $query->is_main_query() ) {
    $query->set( 'post_type', array('post', 'blog' ) );
    }
  }
  add_action( 'pre_get_posts', 'add_cpt_author' );