'Invalid value in field "itemtype" in Google Search Console

I am using the Jupiter theme in Wordpress. I created a new blog post and when submitted the same in Google Search Console/webmaster, I got the following error by google while doing the page crawling.

The error which is highlighted by google is:

Invalid value in field "itemtype"

<div class="mk-single-comment" id="comment-5322" itemprop=&quot;comment&quot; itemscope=&quot;itemscope&quot; itemtype=&quot;https://schema.org/Comment&quot; >

Invalid value in field "itemtype"



Solution 1:[1]

Got this fixed! The problem is with the Unparsable structured data " which google has detected as invalid.

Here is the solution which worked for me.

The problem was with the HTML code of the comment section in my blog. So, I went into the Jupiter theme source code: /var/www/html/wp-content/themes/jupiter/comments.php

And, removed all esc_attr(). Once I did that all " disappeared :)

Primarily you have to do these replacements in line no. 5, 8, 11 and 26.

Original code:

function theme_comments( $comment, $args, $depth ) {
        $GLOBALS['comment'] = $comment; ?>
        <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
                <div class="mk-single-comment" id="comment-<?php comment_ID(); ?>" <?php echo esc_attr( get_schema_markup( 'comment' ) ); ?>>
                        <div class="gravatar"><?php echo get_avatar( $comment, $size = '45', $default = '' ); ?></div>
                        <div class="comment-meta">
                                        <?php printf( '<span class="comment-author" ' . esc_attr( get_schema_markup( 'comment_author_link' ) ) . '>%s</span>', get_comment_author_link() ); ?>

                                        <?php edit_comment_link( '', '', '' ); ?>
                                        <time class="comment-time" <?php echo esc_attr( get_schema_markup( 'comment_time' ) ); ?>><?php echo get_comment_date(); ?></time>
                        </div>
                        <span class="comment-reply">
                                        <?php
                                        comment_reply_link(
                                                array_merge(
                                                        $args, array(
                                                                'depth' => $depth,
                                                                'max_depth' => $args['max_depth'],
                                                        )
                                                )
                                        );
?>
                        </span>
                        <div class="clearboth"></div>
                        <div class="comment-content" <?php echo esc_attr( get_schema_markup( 'comment_text' ) ); ?>>
                                        <?php comment_text(); ?>

<?php if ( '0' == $comment->comment_approved ) : ?>
                                        <span class="unapproved"><?php esc_html_e( 'Your comment is awaiting moderation.', 'mk_framework' ); ?></span>
<?php endif; ?>
                                <div class="clearboth"></div>
                        </div>


                           </div>
<?php
}

Code with replaced **esc_attr():**

function theme_comments( $comment, $args, $depth ) {
        $GLOBALS['comment'] = $comment; ?>
        <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
                <div class="mk-single-comment" id="comment-<?php comment_ID(); ?>" <?php echo get_schema_markup( 'comment' ); ?>>
                        <div class="gravatar"><?php echo get_avatar( $comment, $size = '45', $default = '' ); ?></div>
                        <div class="comment-meta">
                                        <?php printf( '<span class="comment-author" ' . get_schema_markup( 'comment_author_link' ) . '>%s</span>', get_comment_author_link() ); ?>

                                        <?php edit_comment_link( '', '', '' ); ?>
                                        <time class="comment-time" <?php echo get_schema_markup( 'comment_time' ); ?>><?php echo get_comment_date(); ?></time>
                        </div>
                        <span class="comment-reply">
                                        <?php
                                        comment_reply_link(
                                                array_merge(
                                                        $args, array(
                                                                'depth' => $depth,
                                                                'max_depth' => $args['max_depth'],
                                                        )
                                                )
                                        );
?>
                        </span>
                        <div class="clearboth"></div>
                        <div class="comment-content" <?php echo get_schema_markup( 'comment_text' ); ?>>
                                        <?php comment_text(); ?>

<?php if ( '0' == $comment->comment_approved ) : ?>
                                        <span class="unapproved"><?php esc_html_e( 'Your comment is awaiting moderation.', 'mk_framework' ); ?></span>
<?php endif; ?>
                                <div class="clearboth"></div>
                        </div>


                           </div>
<?php
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dibya Sahoo