Black Friday Sale! Get $20 off GP Premium, $40 off our new Lifetime license, and 45% off license renewals/extensions! Learn more

[Resolved] Change 'itemtype='http://schema.org/WebPage' Function

Home Forums Support Change 'itemtype='http://schema.org/WebPage' Function

  • This topic has 3 replies, 2 voices, and was last updated 3 years ago by Tom.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #414135
    scott doel

    Hi is it possible to unhook the itemtype='http://schema.org/WebPage and replace it with the below?

    <?php if ( is_page( array( 'about', 'about-us' ) ) ) { echo 'itemscope itemtype="http://schema.org/AboutPage"';
    } elseif ( is_page( array( 'contact', 'contact-us' ) ) ) { echo 'itemscope itemtype="http://schema.org/ContactPage"';
    } elseif ( is_search () ) { echo 'itemscope itemtype="http://schema.org/SearchResultsPage"';
    } elseif ( is_front_page () ) {	echo 'itemscope itemtype="http://schema.org/WebPage"';
    } elseif (is_single () ) { echo 'itemscope itemtype="http://schema.org/Article"';
    } else { echo 'itemscope itemtype="http://schema.org/WebPage"'; // just in case we are at an unclassified page, perhaps the home page
    } ?>
    GeneratePress 1.4
    GP Premium 1.4.3
    #414381
    Tom
    Lead Developer
    Lead Developer

    You could do this:

    add_filter( 'generate_body_itemtype', 'tu_custom_body_itemtype' );
    function tu_custom_body_itemtype( $type ) {
        if ( is_page( array( 'about', 'about-us' ) ) ) { 
            return 'AboutPage';
        } elseif ( is_page( array( 'contact', 'contact-us' ) ) ) { 
            return 'ContactPage';
        } elseif ( is_search() ) { 
            return 'SearchResultsPage';
        } elseif ( is_front_page() ) {
            return 'WebPage';
        } elseif (is_single() ) {
            return 'Article';
        } else {
            return 'WebPage';
        }
    }
    #415026
    scott doel

    Sorry for the late response Tom, the snippet above worked perfectly thank you

    #415073
    Tom
    Lead Developer
    Lead Developer
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.