Adding schema.org itemprop to WP4.1 Title Tag

If your theme is using add_theme_support('title-tag'), then you can try the following:

remove_action( 'wp_head', '_wp_render_title_tag', 1 );

and then just hook in your own modified version:

add_action( 'wp_head', 'wpse_render_title_tag_with_itemprop', 1 );

function wpse_render_title_tag_with_itemprop() {

    if ( did_action( 'wp_head' ) || doing_action( 'wp_head' ) ) 
    {     
        printf( 
            '<title itemprop="name">%s</title>' . PHP_EOL, 
             wp_title( '|', false, 'right' )
        );
    }
}

with the title tag containing the itemprop attribute.

Note: The current_theme_supports( 'title-tag' ) is using debug_backtrace() to check if it was called within the _wp_render_title_tag() or wp_title() functions:

if ( 'title-tag' == $feature ) {
    // Don't confirm support unless called internally.
    $trace = debug_backtrace();
    if ( ! in_array( $trace[1]['function'], array( '_wp_render_title_tag', 'wp_title' ) ) ) {
        return false;
    }
 }

Also note that if we would have used:

add_action( 'after_setup_theme', function() {
        remove_theme_support( 'title-tag' );
}, 11 );

which is equivalent to:

global $_wp_theme_features;
unset( $_wp_theme_features['title-tag'] );

then the following part of wp_title() would be excluded:

if ( current_theme_supports( 'title-tag' ) && ! is_feed() ) {
    $title .= get_bloginfo( 'name', 'display' );

    $site_description = get_bloginfo( 'description', 'display' );
    if ( $site_description && ( is_home() || is_front_page() ) ) {
        $title .= " $sep $site_description";
    }

    if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
        $title .= " $sep " . sprintf( __( 'Page %s' ), max( $paged, $page ) );
    }
}

The title tag could therefore become empty on the front-page, for example.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)