Home Forums Tutorials and Hints from Users Eliminate Google structured data Hatom errors on WordPress sites.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #18028
    HansPrive
    Participant

    I recently stumbled on this article to eliminate Google structured data Hatom errors on WordPress sites: http://swampsidestudio.com/remove-wordpress-hentry-class/

    Many WordPress themes, even WordPress default themes, use post_class on all content, including pages. WordPress pages, as opposed to posts, don’t usually include a date and author because pages are not date based. Google’s Structured Data Testing Tool sees the hentry class and expects to see date and author, so it lists errors.

    Solution: Remove WordPress hentry Class from Pages.

    Question: where should I add the coding lines in WeaverII-pro? Advanced options/<head>section/Actions and filters?
    #23368
    Weaver
    Keymaster

    Add the filter as found in the article:

    function themeslug_remove_hentry( $classes ) {
        if ( is_page() ) {
            $classes = array_diff( $classes, array( ‘hentry’ ) );
        }
        return $classes;
    }
    add_filter( ‘post_class’,’themeslug_remove_hentry’ );

    directly, as is (although you could change ‘themeslug’ to ‘weaverii’ or something else unique), into the Advanced Options : <HEAD> Section : Actions and Filters box. I tested it and it works.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.