Hentry is not working

I did what the previous posts said and added the below function, and then cleared the cache, and it’s still not working.
The author, title, are missing just like everyone else.

function add_suf_hatom_data($content) {
$t = get_the_modified_time(‘F jS, Y’);
$author = get_the_author();
$title = get_the_title();
if (is_home() || is_singular() || is_archive() ) {
$content .= ‘

’.$title.’ was last modified: ‘.$t.’ by ‘.$author.’
’;
}
return $content;
}
add_filter(‘the_content’, ‘add_suf_hatom_data’);

This is for the Pro theme

Hi There,

Thank you for writing in, are you trying to display the author and date metadata in your blog posts? If so, you can enable it under Theme Options > Blog > Post Meta

If this is not what you need, please clarify what you’re trying to do.

Cheers!

No that’s not the issue… It’s exactly this issue same problems and same pictures, so I’ll just link to the page.

Hello There,

Thanks for updating in! I have checked your page and I see that the code is working:

It is not reflecting because of your Endurance Page cache. Please clear your page cache first before testing the site. You can temporarily disable this by going to Settings > General > Endurance Page Cache.

Hope this helps.

Thank you… I can’t tell you how many times I tested this, and purged the cache each time with no notable difference. I didn’t really think I needed to turn the cache off, but it worked. Thank you.

Actually I spoke to soon. While the page you pointed out is working properly I have a lot of other pages that are still not working. I’ve purged the cache again, but I had to turn it back on because I probably won’t have a response for another 24 hours, but as you can see I still have 30 some Google errors and it’s increasing now, because it was only 26 when I opened this ticket… I need every single one of them gone!

Hi There,

Try utilizing Snippet extension that comes with X. Please refer to the following guide (https://theme.co/apex/forum/t/extension-snippet/94).

Hope that helps.

I don’t understand. What does that plug-in have to go with the author’s name, update date, and title not appearing under hentry? From my understanding hentry is created by WordPress and has to do with the information from the blog which is already there.

I shouldn’t need the snippet plug-in to fix this error.

It looks like there are only two pages with the error now the blog page with 10 errors and our privacy page.

Hello There,

Please update the code and use this:

function add_suf_hatom_data($content) {
	$t      = get_the_modified_time('F jS, Y');
	$author = get_the_author();
	$title  = get_the_title();
	
	if (is_page() || is_home() || is_singular() || is_archive() ) {
		$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_suf_hatom_data');

After making the changes, clear the Page Endurance cache first before testing the site.

@RueNel that the best suggestion so far and works on everything, except the blog page /blog
I have ten errors basically one for each post on the page.

Hey There,

The blog index or any archive page is using the excerpts and not the content. This could be the reason why it is not working in the blog index. Please have the code updated and use this:

function add_suf_hatom_data($content) {
	$t      = get_the_modified_time('F jS, Y');
	$author = get_the_author();
	$title  = get_the_title();
	
	if (is_page() || is_home() || is_singular() || is_archive() ) {
		$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_suf_hatom_data');
add_filter('the_excerpt', 'add_suf_hatom_data');

Hope this helps. Please let us know how it goes.

The structured data is working perfectly now. Thanks for the help @RueNel

Glad to hear that :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.