Skip to content

Instantly share code, notes, and snippets.

@zeshanshani
Last active September 20, 2018 08:11
Show Gist options
  • Save zeshanshani/76feb3e186d896afff94 to your computer and use it in GitHub Desktop.
Save zeshanshani/76feb3e186d896afff94 to your computer and use it in GitHub Desktop.
WordPress fix for "Missing Author" and "Missing Updated Date" Google structured data errors.
.hatom-extra {
font-style: italic;
margin-top: 10px;
padding-top: 10px;
font-size: 12px;
}
<?php
//
// By Zeshan Ahmed
// URI: http://www.zeshanahmed.com/
//
/* Fix "Missing Author" and "Missing Updated" issue - START */
add_filter( 'the_content', 'custom_author_code');
function custom_author_code($content) {
if (is_singular() || is_single()) {
return $content . '<div class="hatom-extra"><span class="title">'. get_the_title() .'</span> was last modified: <span class="updated"> '. get_the_modified_time('F jS, Y') .'</span> by <span class="author vcard"><span class="fn">'. get_the_author() .'</span></span></div>' ;
} else {
return $content;
}
}
/* Fix "Missing Author" and "Missing Updated" issue - END */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment