The New Google Structured Data Testing Tool Gives Error Against Genesis HTML5 Child Themes. Commenting Out Three Lines Will Fix This Issue. According to IBM , Microdata is a simple way to add structured data on the web page. It defines several attributes, such as item type and itemprop, can be placed in the HTML tag to indicate what the page is about. Microdata was introduced in 2009 by Ian Hickson, the editor of the HTML5 specification. However, the origin of this idea before long. In this guide we will fix WordPress mainContentOfPage Schema error for Genesis child themes.
Why mainContentOfPage Schema Gives Error in Genesis Child Themes?
The practical answers are two – first is Google.
From their logic :
---
As we are using mainContentOfPage, you probably want to have a WebPage item. But this property can not have Blog as value, it needs to be a WebPageElement. So, removing itemprop="mainContentOfPage"
is the right approach. You need not to become an expert of WordPress template hierarchy. You only need to do SSH and edit a file or edit from SFTP.
Secondly, the people who are involved in the development of the paid themes, rarely has a Masters degree on science related subject – you can forget about a degree on software engineering. All together, somehow running.
Fix WordPress mainContentOfPage Schema Error (Genesis)
If you add filter on Genesis child theme’s functions.php
file, it will actually increase at least two query. One is from core of Genesis – which will direct to inject the snippet, another you added – on Genesis child theme’s functions.php
file. If you comment out the function from the core of Genesis, you are decreasing one query. Only problem is that, you have to remember to do it every-time you update Genesis, till they fix it somehow. We are using Nginx on deb Linux, so our this file :
1 | ./wp-content/themes/genesis/lib/functions/markup.php |
will be at :
1 | /usr/share/nginx/html/wp-content/themes/genesis/lib/functions |
… directory.
Genesis core files will bear “do not edit”, because it is pseudo Free Software. This is not Linux Kernel file, it is just a basic PHP file. You will not die by editing it. So we did an SSH to server, changed role as root
user and changed directory to :
1 | cd usr/share/nginx/html/wp-content/themes/genesis/lib/functions && ls |
Run this command there :
1 | cat markup.php | grep Blog |
You will get these :
1 2 3 | //* Blog microdata //* Blog posts microdata $attributes['itemtype'] = 'http://schema.org/Blog'; |
Open the file in nano :
1 | nano markup.php |
Find the phrase Blog with search ( ^ + W
) function of Nano. You will find :
1 2 3 4 5 | //* Blog microdata if ( is_singular( 'post' ) || is_archive() || is_home() || is_page_temp$ $attributes['itemscope'] = 'itemscope'; $attributes['item type'] = 'http://schema.org/Blog'; } |
Comment it out :
1 2 3 4 5 6 7 8 9 10 | function genesis_attributes_content( $attributes ) { $attributes['role'] = 'main'; $attributes['itemprop'] = 'mainContentOfPage'; //* Blog microdata // if ( is_singular( 'post' ) || is_archive() || is_home() || is_page_temp$ // $attributes['itemscope'] = 'itemscope'; // $attributes['item type'] = 'http://schema.org/Blog'; // } |
Write out with ^ + O
and exit nano with ^ + O
. Clear W3 Total Cache’s all Cache. Test it with the new Google Structured data testing tool. You will not get any error. If you have Genesis Simple Hooks plugin installed, you can go to the filed named genesis_before_entry Hook (under Entry Hooks) and add :
1 2 | <span itemprop="genre" content="Technology"> <span itemprop "additionalType" content="Article"> |
You should add the values Technology
and Article
if it matches your niche. Else check the schema.org
documentation. Again flush the cache and test. Right now, we have some errors related to JSON-LD plus our markup things are very complicated. Do not test ours, you might get confused.
Genesis like themes are not real Free Softwares, we can not see the diff for the next upgrade. So you have to manually do the works again.
Update for Genesis 2.2.6
All is same, except, search for the word CreativeWorks
and change it to Article
. They have not understood the stuff yet.
Update for Genesis 2.3
All is same, except —
– they kept the classification as CreativeWorks
, hence you may and change it to Article
. They have not understood the stuff and avoided complication. Just bad cheat.
– mainContentOfPage has been vanished.
Tagged With https://thecustomizewindows com/2015/04/fix-wordpress-maincontentofpage-schema-error-genesis/ , word press where to change itemprop=mainContentOfPage