wordpress Missing required field entry-title updated hCard author

Under google webmaster tools structured data, you may found the following error on your wordpress web pages:

Error: Missing required field "entry-title".
Error: Missing required field "updated".
Error: Missing required hCard "author".

We need to apply following fix in single.php from theme directory

Fix – Missing required field "entry-title"

Change

<h1 class="title"><?php the_title(); ?></h1>

to

<h1 class="title entry-title"><?php the_title(); ?></h1>

Fix – Missing required field "updated".

Change

<span class="date"><?php the_time(‘Y-m-d’); ?></span>

to

<span class="date updated"><?php the_time(‘Y-m-d’); ?></span>

Fix – Missing required hCard "author"

Change

<?php the_author(); ?>

to

<span class="vcard author"><span class="fn"><?php the_author(); ?></span></span>

If you prefer not to show up such parameters public, you can hide it from background. Just add the following to functions.php, it’s a solution from wordpress forum.

function add_hatom_data($content) {
    $t = get_the_modified_time(‘F jS, Y’);
    $author = get_the_author();
    $title = get_the_title();
if (is_singular()) {
        $content .= ‘<div class="hatom-extra" style="display:none;visibility:hidden;"><span class="entry-title">’.$title.’</span> was last modified: <span class="updated"> ‘.$t.’</span> by <span class="author vcard"><span class="fn">’.$author.’</span></span></div>’;
    }
    return $content;
    }
add_filter(‘the_content’, ‘add_hatom_data’);

Share

- has written 121 posts.


Leave a Reply

You must be logged in to post a comment.