Fix Google Structured Data hentry Markup Errors in WordPress

Fix markup hentry errors

I guess you recently signed up with Google Search Console (or Google Webmasters). Then you submitted your blog site, wishing that you will have a good rank in organic search, configured and explored the settings of your property and found out some problems in the Search Appearance > Structured Data menu. Oh no! What to do know? This might greatly affect my ranking in search results! Hey. Don’t panic. You are not the only WordPress blogger that is encountering this issue. In fact, most of the wordpress bloggers that uses typical themes found in WordPress.org have this missing entries or structured data markup errors in their Google Webmaster Tools. This is mainly an issue with the wordpress core itself and some theme authors do not even care about proper SEO techniques (or I should say, markup entries) to include. I’m not saying all because I already tried themes that have native support for structured data microformats and even Schema.org entries.

FIX GOOGLE STRUCTURED DATA MARKUP ERRORS IN WORDPRESS

So, let’s begin. The screenshot below may seem familiar to you. It is a snapshot of my Search Console or Google Webmaster Tools for one of my blogs.

hentry-errors

As you can see, each article and even category pages shows missing entries for the following: author, entry-title, and updated.

Missing: author
Missing: entry-title
Missing: updated

These entries are crucial for Google Bot to easily read and understand your blog. It doesn’t mean that titles of article will not appear in Google search but it is how Google understand and index your posts.

The author entry supplies the proper credential for who had written a said post and for copyright as well. The entry-title speaks for the post title itself while updated supplies the most recent data when the post is altered by the writer/website owner.

HOW TO FIX IT

There are various solutions over the internet that instructs you/us to put div classes on each post on single.php file of our theme. However, this technique doesn’t always work and the same happened to me. I came up to this solution that easily fixed my problem. Include the following lines in your theme’s functions.php file. This file can be found at Appearance > Editor in your WordPress Admin Dashboard. It is recommended to insert the lines right after the last function found in functions.php or just above the ?> mark.

//Add hatom data structure

function add_hatom_data_structure($content) {
date_default_timezone_set('Asia/Manila');
$t = get_the_modified_time('c');
$author = get_the_author();
$title = get_the_title();
$pt= get_the_date('c');
if (is_home() || is_front_page() || is_singular() || is_page() || is_archive() || is_category() ) {
$content .= '<div class="hatom-extra" style="display:none;visibility:hidden;"><span class="entry-title">'.$title.'</span> is published on <span class="published">'.$pt.'</span> and 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_structure');

Some themes do not have the php closing tag ?> in functions.php. If this is the case, just insert the lines in the bottom.

This function will provide the entry-title, updated date and author entries in hatom/hentry structured data markup. You can tweak this code according your liking like removing some of the if declaration. Also, the default timezone is set to Asia/Manila (GMT +8) because this is the area where I live. Timezone codes for your area can be found here: PHP List of Supported Timezones. You may be wondering why do include this line. The primary reason is that google structured data helper only see the timezone at UTC default whatever timezone you had set in WordPress settings. Basically, the lines

date_default_timezone_set('Asia/Manila');
$t = get_the_modified_time('c');

are independent on your wordpress default settings. You can know more about the options for get_the_modified_time value in WordPress Codex.

Recommended Reading: Tips on How to Get Fast Google Adsense Approval with a New Blog

CHECK IT WITH GOOGLE STRUCTURED DATA TESTING TOOL

Google takes time to reindex your files even if you had requested such. The time it will take just to know if the problem is already fixed can not be tolerated by most of the webmasters. To check if you implemented the code well, use the Google Structured Data Testing Tool. Input the address of the blog post you like to check and look for hatom/hentry entries if they appear correctly.

hentry-noerrors

The snapshot above shows a sample output of the testing tool where the hatom function is implemented correctly.

CLARIFICATIONS

The missing entries and errors in structured data do not affect your ranking in organic search results. However, do not think this rich snippets are useless for SEO. These are used to properly present your pages especially if your blog is a review site. These things are not covered by this post and you better look for explanations how this markup can help you improve your blog.

Anyway, who wants to have those red exclamation icons in their accounts? It is way better to get rid of them and then relax.

Recommended Reading: Ruined Blog Visits: WordPress .GZ Compressed File

TROUBLESHOOTING

If the tool still show errors or missing the required lines, please beĀ  sure that you already cleared or purged your cache file if you are using any caching solution.

If you still encounter problems implementing the code, do not hesitate to reach me by leaving a comment below.

Scroll to top