Display page and custom post title inside shortcode

I trying to write shortcode to display page title but only got the archive title to work but not custom post type category and single post. Can anyone shed light how to do this? Reason for going this path is Elemenentor theme builder generate too much code for simple page title and subheading inside secondary header that is masked wrap around image. I use the shortcode widget to insert the code and style it.

So far this is what I have written:

// Page Title inside shortcode function page_title_sc( ) {     $  title = ('Page Title');     if ( is_post_type_archive() ) {     $  title = post_type_archive_title( '', false );   }   elseif ( is_page() ) {     $  title = single_post_title();    }     return apply_filters( 'page_title_sc', $  title ); }   add_shortcode( 'page_title', 'page_title_sc' );