Tagged: x
-
AuthorPosts
-
April 15, 2016 at 12:46 am #883692
Gee RParticipantHi all,
I read with great interest your solution to fixing the “missing author” and “missing updated” hentry errors (see https://community.theme.co/forums/topic/how-to-fix-missing-author-and-missing-updated-errors/).
Since I have the same issue, I tried adding the code mentioned in that thread to my child theme’s functions.php. However it threw up a php error referencing another mod I have which auto-adds the Author box to all blog posts (which I got from https://community.theme.co/forums/topic/add-authors-meta-next-to-post-entrys-text/ )
The php error that I get is:
“PHP message: PHP Fatal error: Cannot redeclare custom_author_code() (previously declared in –path to–/wp-content/themes/x-child/functions.php:34) in –path to–/wp-content/themes/x-child/functions.php on line 99″ while reading response header from upstream
(I’ve appended “–path to–” to the above to help keep things clear)
FYI line 34 refers to function custom_author_code($content) { in the following:
add_filter( 'the_content', 'custom_author_code'); function custom_author_code($content) { if ( is_singular('post') ) { return $content . do_shortcode('[x_author title="About the Author"]') ; } else { return $content; } }and line 99 refers to the final curly bracket (i.e. ‘}’ ) in:
add_filter( 'the_content', 'custom_author_code'); function custom_author_code($content) { if (is_singular() || is_single()) { return $content . '<div class="hatom-extra hidden"><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; } }How do I have both mods play nicely with each other?
Thanks in advance for any help you can offer.
April 15, 2016 at 6:16 am #884118
ZeshanMemberHi there @Gee,
Thanks for writing in!
To fix the issue, replace the second instance of the code with this:
add_filter( 'the_content', 'fix_google_hentry_errors'); function fix_google_hentry_errors($content) { if (is_singular() || is_single()) { return $content . '<div class="hatom-extra hidden"><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; } }Hope this helps. 🙂
Thank you!
April 15, 2016 at 6:29 am #884139
Gee RParticipantThank you so much.
The solution was as simple as naming the function something else? D’oh!
April 15, 2016 at 5:13 pm #884945
JadeModeratorGlad to hear it’s now sorted. 🙂
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-883692 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
