• Hi
    I set up Google Tag Manager yesterday for my website. But as soon as I did that, some text “itemtype=”https://schema.org/WebPage” itemscope>” started appearing on every page of my site.
    I don’t have much knowledge of coding. Can someone please guide me step by step about how can I can fix it?

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Theme Author Tom

    (@edge22)

    Hi there,

    Can you share the code you added/how you added it when you set up GTM?

    Thread Starter skycheerful

    (@skycheerful)

    I added it in my header.php file after <head> and <body> as instructed in GTM. Complete code of my header looks like this:
    `<?php
    /**
    * The template for displaying the header.
    *
    * @package GeneratePress
    */

    if ( ! defined( ‘ABSPATH’ ) ) {
    exit; // Exit if accessed directly.
    }

    ?><!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    <head>
    <!– Google Tag Manager –>
    <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({‘gtm.start’:
    new Date().getTime(),event:’gtm.js’});var f=d.getElementsByTagName(s)[0],
    j=d.createElement(s),dl=l!=’dataLayer’?’&l=’+l:”;j.async=true;j.src=
    https://www.googletagmanager.com/gtm.js?id=’+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,’script’,’dataLayer’,’GTM-55M6XZ8′);</script>
    <!– End Google Tag Manager –>
    <meta charset=”<?php bloginfo( ‘charset’ ); ?>”>
    <link rel=”profile” href=”https://gmpg.org/xfn/11″&gt;
    <?php wp_head(); ?>
    </head>

    <body <?php body_class(); ?>
    <!– Google Tag Manager (noscript) –>
    <noscript><iframe src=”https://www.googletagmanager.com/ns.html?id=GTM-55M6XZ8&#8243;
    height=”0″ width=”0″ style=”display:none;visibility:hidden”></iframe></noscript>
    <!– End Google Tag Manager (noscript) –>
    <?php generate_do_microdata( ‘body’ ); ?>>
    <?php
    /**
    * wp_body_open hook.
    *
    * @since 2.3
    */
    do_action( ‘wp_body_open’ ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound — core WP hook.

    /**
    * generate_before_header hook.
    *
    * @since 0.1
    *
    * @hooked generate_do_skip_to_content_link – 2
    * @hooked generate_top_bar – 5
    * @hooked generate_add_navigation_before_header – 5
    */
    do_action( ‘generate_before_header’ );

    /**
    * generate_header hook.
    *
    * @since 1.3.42
    *
    * @hooked generate_construct_header – 10
    */
    do_action( ‘generate_header’ );

    /**
    * generate_after_header hook.
    *
    * @since 0.1
    *
    * @hooked generate_featured_page_header – 10
    */
    do_action( ‘generate_after_header’ );
    ?>

    <div id=”page” <?php generate_do_element_classes( ‘page’ ); ?>>
    <?php
    /**
    * generate_inside_site_container hook.
    *
    * @since 2.4
    */
    do_action( ‘generate_inside_site_container’ );
    ?>
    <div id=”content” class=”site-content”>
    <?php
    /**
    * generate_inside_container hook.
    *
    * @since 0.1
    */
    do_action( ‘generate_inside_container’ );

    Leo

    (@leohsiang)

    Never a good idea to edit the theme files as it will be erased during updates.

    Try this instead:

    add_action( 'wp_head', function() {
    ?>
    // Add your code here 
    <?php
    }); 

    And replace // Add your code here with the actual script copy from Google.

    The PHP snippet above can be added using one of these methods:
    Adding PHP: https://docs.generatepress.com/article/adding-php/

    The Code Snippets plugin is the easiest solution ??

    Leo

    (@leohsiang)

    Also make sure you revert the header.php file back to the original state:
    https://github.com/tomusborne/generatepress/blob/master/header.php

    Thread Starter skycheerful

    (@skycheerful)

    @leohsiang And how to insert code after body tag?

    Leo

    (@leohsiang)

    I assume you meant right before the end of body tag?

    If so this should work:

    add_action( 'wp_footer', function() {
    ?>
    // Add your code here 
    <?php
    }); 
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Schema Code appearing on top of every page’ is closed to new replies.