Simon Social Media Jan 28, 2017 · 5:16 pm #5823 Hi,
In Google Webmaster I’m seeing the following errors:
Missing: author
Missing: entry-title
Missing: updated
This is summarised in this article but I can’t work out where I find single.php and if this is a common problem with the Ultra theme?
https://www.acceleratormarketing.com/trench-report/google-analytics-errors-and-structured-data/
Any advice on how to resolve?
Thank you.
Andrew Misplon Puro Jan 28, 2017 · 8:36 pm #5825 Hi Simon
The issue is WordPress using a class called hentry on pages and posts. Ideally, it needs to be removed from pages. Structured data is intended for syndicated content, meaning posts. Here is how I recommend fixing:
1. Plugins > Add New, install Code Snippets plugin, activate.
2. Snippets > Add New, name as you’d like and insert the following in the snippet body:
if ( ! function_exists( 'ultra_post_class_filter' ) ) :
/**
* Filter post classes.
* @link https://codex.wordpress.org/Function_Reference/post_class.
*/
function polestar_post_class_filter( $classes ) {
$classes[] = 'post';
// Resolves structured data issue in core. See https://core.trac.wordpress.org/ticket/28482.
if ( is_page() ) {
$class_key = array_search( 'hentry', $classes );
if ( $class_key !== false) {
unset( $classes[ $class_key ] );
}
}
$classes = array_unique( $classes );
return $classes;
}
endif;
add_filter( 'post_class', 'ultra_post_class_filter' );
There is a link in the function to read about this issue on wp.org if you want to.
Finally, select the option to only run the snippet on the site front-end and click Save changes and activate.
Also, make sure that all the meta settings are enabled at Appearance > Customize > Theme Settings > Blog. If you disable the author output for example, that info will be missing from single posts.
Simon Social Media Jan 29, 2017 · 2:36 pm #5830 Hi Andrew – that seems to have done the trick, thank you very much!
Andrew Misplon Puro Jan 29, 2017 · 7:24 pm #5832 Great 🙂 Really glad to hear that did the trick. All the best.
Reid Oct 2, 2017 · 4:31 pm #7930 Hi Andrew,
I am having the same issue with console not recognizing the author, title and updated info. Rather than start a new thread, I did a search and found this one. I followed your instructions regarding adding the snippets plugin and received the following errors above each post on my blog page (https://www.aixploringprovence.com/blog-journal/):
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘ultra_post_class_filter’ not found or invalid function name in /home7/aixplori/public_html/wp-includes/class-wp-hook.php on line 300
Warning: array_unique() expects parameter 1 to be array, null given in /home7/aixplori/public_html/wp-includes/post-template.php on line 545
Warning: join(): Invalid arguments passed in /home7/aixplori/public_html/wp-includes/post-template.php on line 423
class=””>
I’ve deactivated the plugin for now (to remove the ugly error messages from the page) until I hear back about what this means and if I may have done something incorrectly?
Thanks for any advice you may have.
Andrew Misplon Puro Oct 2, 2017 · 4:39 pm #7931 Hi Reid
Thanks for reaching out 🙂
Please, can you post this as a new topic. We do our best to work a thread per user per issue. It’s great to jump if you can offer help on an open issue but if you have a fresh question, even if it’s related, we prefer to work a new topic. That way the initial poster doesn’t get notifications and there isn’t any confusion with differing setups for a similar issue.
You’re a premium user so you’re also welcome to reach out via email: [email protected].