text is appearing at the top left of my wordpress

2019-08-11 02:14发布

I have seen a few threads about this but have not seen any solutions that have worked for me so far.

My wordpress site (www.strantech.com) appears to be showing code at the top left on every page that definitely should not be there. I am assuming there is a spacing issue that I cannot spot as a novice coder.

From what the other boards suggested, it seems to be related to an issue in the header.

I have pasted my header below for your convenience.

<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width" />
<meta HTTP-EQUIV="Pragma" content="no-cache">
<meta HTTP-EQUIV="Expires" content="-0">
<title><?php wp_title( '|', true, 'right' ); ?></title>
<!-- Favicon -->
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<link rel="stylesheet" type="text/css" media="all" href="<?php echo get_template_directory_uri(); ?>/css/lightbox.css" />
<link rel="stylesheet" type="text/css" media="all" href="<?php echo get_template_directory_uri(); ?>/css/QapTcha.jquery.css" />
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" />
<?php // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?>
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
<![endif]-->
<?php wp_head(); ?>
    <script>
        window.themePath = '<?php echo get_template_directory_uri(); ?>';
   <script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-41041086-1', 'auto');
  ga('send', 'pageview');

</script>
</head>

Can anyone provide advice on what the issue might be and how to fix it? Thanks in advance.

Cheers, Jake

标签: php wordpress
2条回答
The star\"
2楼-- · 2019-08-11 02:38

Be sure to paste the snippet immediately after the opening <body> tag in your Wordpress template. It may look something like this:

<body <?php body_class(); ?>>

So immediately after that is where you paste your snippet.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-08-11 02:46

It's not in the header. It right after that where the <body> tag is:

<body <!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-NN644H"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<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=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-NN644H');</script>
<!-- End Google Tag Manager --> class="home page page-id-2 page-template-default">

Remove everything to the right of <!-- End Google Tag Manager -->

查看更多
登录 后发表回答