Itemref error
-
Hi George,
I’m almost ready to buy you a coffee.
I’ve used the google structured data testing tool in order to see what comes up here.
I am getting this error on post pages (my blog is called a magazine):
The error says that the attribute “itemref” points to a non-existent identifier comments
We have comments disabled on my website by default.
<!-- BEGIN Microdata added by Add-Meta-Tags WordPress plugin --> <!-- Scope BEGIN: Article --> <div itemscope itemtype="https://schema.org/Article" itemref="comments"> <!-- Scope BEGIN: Organization -->
The following theme code is in my functions.php file
I had to change blogPost to BlogPosting in order to conform to the current schema.org format// functions to aid in Schema.org structured data creation function yeast_schema_type() { if (is_single()) { $item_type = 'BlogPosting'; } elseif (is_blog() || is_archive()) { $item_type = 'Blog'; /*} elseif (is_search()) { $item_type = 'SearchResultsPage';*/ } else { $item_type = 'WebPage'; } if (!is_singular('product')) { echo 'itemscope itemtype="https://schema.org/'.$item_type.'"'; } }
This code was added to as author, date published etc were not in the theme code.
//mod content function hatom_mod_post_content ($content) { if ( in_the_loop() && !is_page() ) { $content = '<span class="entry-content">'.$content.'</span>'; } return $content; } add_filter( 'the_content', 'hatom_mod_post_content'); //add hatom data function add_mod_hatom_data($content) { $t = get_the_modified_time('F jS, Y'); $author = get_the_author(); $title = get_the_title(); if(is_single()) { $content .= '<div class="hatom-extra"><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_mod_hatom_data');
Thank you for any help. My website dev hasn’t got a clue about this [although he took my $$ gladly] and I’ve spent a week trying to get it resolved.
PS This plugin is working great on my woocommerce products pages.
- The topic ‘Itemref error’ is closed to new replies.