Add hentry Schema Markup on WordPress Website using Function

Add simple php code on functions.php then make more suitable article for search engines. You can also use article type markup on website.

How to Do

  • Open active theme’s functions.php file.
  • Paste Code and SAVE.
  • Then check pasted code from Schema Validator for satisfaction.

Code

function thekroyaard_hentry_code($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 .= '<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', 'thekroyaard_hentry_code');

If you want to add hentry markup using class so Read Article,  and Hope this code work perfectly, If any error on this code so contact us. Thank for vising.