How to fix Google Search Console Structured Data hentry errors.
Hi All,
If you look in google search console and your get errors that look like this:
Then you'll need to do some editing to make them go away. Here's how I did it.
If you haven't created a child theme for the theme you are working with in WP, then I'd do that first. I'm sure there are great posts on here about doing this, but if you don't want to mess with code, then search in the plugins area for One-Click Child Theme:
https://wordpress.org/plugins/one-click-child-them...
This makes using it SUPER simple to create one. The short on why you want this, is say you need to do something to your code that "fixes" an issues such as this one.. editing the theme's code will potentially reverse the changes when they update the theme. Child themes inherit all the core theme features from the parent, and keep your changed parts. = )
So.. after doing this, you'll want to start editing your code. Go to Appearance - > Editor -> and in the top right make sure you're editing your child theme. Then, in your funcitons.php file, paste in the following code to the bottom:
// auto insert hidden hatom data in single posts
add_filter('the_content', 'hatom_data_in_content', 100);
function hatom_data_in_content($content) {
if (is_single()) $content .= get_hatom_data();
return $content;
}
// returns hidden hatom data for current post
function get_hatom_data() {
$html = '<div class="hatom-extra" style="display:none;visibility:hidden;" rel="display:none;visibility:hidden;">';
$html .= '<span class="entry-title">'.get_the_title().'</span>';
$html .= '<span class="updated"> '.get_the_modified_time('F jS, Y').'</span>';
$html .= '<span class="author vcard"><span class="fn">'.get_the_author().'</span></span></div>';
return $html;
}
Next, use the side-bar on the right to find either your page.php or your archive.php file, whichever you happen to have in your theme.
Find the beginning of the <?php while ( have_posts() ) : the_post(); ?> loop.
Next, find the start of the <div there should only be one opening <div in this loop somewhere. After the first opening <div line, past in the following code:
<?php if(function_exists('get_hatom_data')) echo get_hatom_data(); ?>
Now to check it it works!
Go back to Google Search Console and back to the error page. Click on the link of the offending page. You should get a test live data popup.
If it works, you should see quite a few more hentry meta-data referenced on the page. The only thing to do now is to re-index your content, and the errors should be gone.
Cheers!
Recent Comments
7
This is sooo helpful. Have had this problem myself and now I can actually fix it. Thanks very much for sharing.
Glad to help! I figured since it took me some time to figure it out, I'd save that time for someone else if I could. = )
See more comments
Thank you so much! You have explained this in a way I think I can actually do it, no other tutorial has done that! I cannot wait to go and try this!
I will let everyone know how it goes.
Question- You are doing the changes to the child, so when I go to google console to see if its fixed won't it be looking at the parent?
How to I change the parent to the child info after I know its all fixed?
One more question though- do I need to do something specific to "re-index" my content as you stated above?
thank you follow the topic
Dear Ready for this,
Good Day!
How are you making out with your trial?
You may be better and further ahead with taking up your inquiry directly with Jcburt17, since Jcburt17 authored the training.
DRL
Well, I haven't put in the code yet. I found this other tutorial that said to use data highlighter in google webmasters to tell them how to find the missing data. So i tried that first because I was scared of messing with the code.
But it was very time consuming and not sure it even worked, and definitely didn't permanently resolve the problem. So I will probably get brave and do the code thing tomorrow. Just want to make sure I get the right plugin to do the parent/child thing.
I would ask JcBurt17 directly but I don't get the impression he is around too much since his rank is almost 600,000.
Thanks for checking up on me though