Display page and custom post title inside shortcode

Add Below Code For post title, page title, category title , tag title , taxonmy title , Author title .

According to your Needed.

function page_title_sc( ) {

    $title = ('Page Title');

    if ( is_page() || is_singular() ) {
        $title = single_post_title();
    } else if ( is_category() ) {
        $title = single_cat_title( '', false );
    } else if ( is_tag() ) {
        $title = single_tag_title( '', false );
    } else if ( is_author() ) {
        $title="<span class="vcard">" . get_the_author() . '</span>';
    } else if ( is_post_type_archive() ) {
        $title = post_type_archive_title( '', false );
    } else if ( is_tax() ) {
        $title = single_term_title( '', false );
    }

   return apply_filters( 'page_title_sc', $title );
}
 
add_shortcode( 'page_title', 'page_title_sc' );

tech