最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Wordpress site screwed up after adding Facebook Pixel inbetween header tags

matteradmin11PV0评论

Added my facebook pixel code between the header tags on my header.php theme file and now my website is all screwed up and not displaying properly. I tried deleting the facebook pixel code and saving but the website still remains screwed. I'm positive I only deleted the pixel code but I'm scared there's a possibility I may have deleted a small portion of code as well.

I want to try and restore a previous version of the header.php file on Worpress.

Also open to other idea on how to fix this. Thanks!

Here is the header.php code - I am trying to insert the Facebook Pixel code inbetween the header tags. There is also a Google Tag Manager piece of code after the header tags that I haven't included because it doesn't appear correct when copied and pasted into the code below:

<!DOCTYPE html>
<html <?php language_attributes(); ?>>

<head>
<meta charset="<?php bloginfo('charset'); ?>" />

<?php if (is_search()) { ?>
   <meta name="robots" content="noindex, nofollow" /> 
<?php } ?>

<title><?php
//Yoast SEO Plugin
if (defined('WPSEO_VERSION')) {
    wp_title('');
} else {
    //The blog name.
    bloginfo( 'name' );

    //Print the <title> tag based on what is being viewed.
    wp_title( '|', true, 'left' );

    //Blog description for the home or front page.
    $site_description = get_bloginfo( 'description', 'display' );
    if ( $site_description && ( is_home() || is_front_page() ) ) {
        echo " | $site_description";
    }
}
?></title>

<meta name="keywords" content="<?php echo 
get_field('meta_keywords','options'); ?>" />    
<meta name="copyright" content="Copyright &copy;<?php echo date('Y'); ?> <? 
php bloginfo('name'); ?> - <?php bloginfo('description'); ?>">
<meta name="googlebot" content="index, follow">
<meta name="Revisit-after" content="3 Days">
<meta name="Rating" content="General">
<meta name="title" content= "<?php bloginfo('name'); ?>" />
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">       

<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>">
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ? 
>/css/normalize.css">
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ? 
 >/css/bootstrap.css">  
<link href="<?php echo get_template_directory_uri(); ?>/favicon.ico" 
rel="shortcut icon" type="image/x-icon" />    
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>">  


<?php if ( is_singular() ) wp_enqueue_script('comment-reply'); ?>

<?php wp_head(); ?>

</head>

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

<div id="page-wrap">
    <div class="header-nav">
        <div id="main-nav" class="navbar navbar-default" role="navigation">
        <div class="container-fluid nav_container">
            <div id="ppts_logo" class="navbar-brand">
            <a href="<?php echo get_bloginfo('url');?>"><img src="<?php 
the_field('logo','options');?>"></a>
            </div>
            <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data- 
toggle="collapse" data-target=".navbar-collapse">           
              <span class="group-icon-bar">
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
            </span>
            </button>
            </div>
            <div class="collapse navbar-collapse">
            <?php wp_nav_menu( array(
                     'menu'              => 'left',
                     'theme_location'    => 'left',
                     'depth'             => 2,                      
                     'menu_class'        => 'nav navbar-nav',
                     'fallback_cb'       => 
 'wp_bootstrap_navwalker::fallback',
                     'walker'            => new wp_bootstrap_navwalker())
                  ); ?> 

            <?php wp_nav_menu( array(
                     'menu'              => 'right',
                     'theme_location'    => 'right',
                     'depth'             => 2,                      
                     'menu_class'        => 'nav navbar-nav navbar-right',
                     'fallback_cb'       => 
 'wp_bootstrap_navwalker::fallback',
                     'walker'            => new wp_bootstrap_navwalker())
                  ); ?>                   
            </div>
        </div>
        </div>
    </div>  

Added my facebook pixel code between the header tags on my header.php theme file and now my website is all screwed up and not displaying properly. I tried deleting the facebook pixel code and saving but the website still remains screwed. I'm positive I only deleted the pixel code but I'm scared there's a possibility I may have deleted a small portion of code as well.

I want to try and restore a previous version of the header.php file on Worpress.

Also open to other idea on how to fix this. Thanks!

Here is the header.php code - I am trying to insert the Facebook Pixel code inbetween the header tags. There is also a Google Tag Manager piece of code after the header tags that I haven't included because it doesn't appear correct when copied and pasted into the code below:

<!DOCTYPE html>
<html <?php language_attributes(); ?>>

<head>
<meta charset="<?php bloginfo('charset'); ?>" />

<?php if (is_search()) { ?>
   <meta name="robots" content="noindex, nofollow" /> 
<?php } ?>

<title><?php
//Yoast SEO Plugin
if (defined('WPSEO_VERSION')) {
    wp_title('');
} else {
    //The blog name.
    bloginfo( 'name' );

    //Print the <title> tag based on what is being viewed.
    wp_title( '|', true, 'left' );

    //Blog description for the home or front page.
    $site_description = get_bloginfo( 'description', 'display' );
    if ( $site_description && ( is_home() || is_front_page() ) ) {
        echo " | $site_description";
    }
}
?></title>

<meta name="keywords" content="<?php echo 
get_field('meta_keywords','options'); ?>" />    
<meta name="copyright" content="Copyright &copy;<?php echo date('Y'); ?> <? 
php bloginfo('name'); ?> - <?php bloginfo('description'); ?>">
<meta name="googlebot" content="index, follow">
<meta name="Revisit-after" content="3 Days">
<meta name="Rating" content="General">
<meta name="title" content= "<?php bloginfo('name'); ?>" />
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">       

<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>">
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ? 
>/css/normalize.css">
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ? 
 >/css/bootstrap.css">  
<link href="<?php echo get_template_directory_uri(); ?>/favicon.ico" 
rel="shortcut icon" type="image/x-icon" />    
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>">  


<?php if ( is_singular() ) wp_enqueue_script('comment-reply'); ?>

<?php wp_head(); ?>

</head>

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

<div id="page-wrap">
    <div class="header-nav">
        <div id="main-nav" class="navbar navbar-default" role="navigation">
        <div class="container-fluid nav_container">
            <div id="ppts_logo" class="navbar-brand">
            <a href="<?php echo get_bloginfo('url');?>"><img src="<?php 
the_field('logo','options');?>"></a>
            </div>
            <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data- 
toggle="collapse" data-target=".navbar-collapse">           
              <span class="group-icon-bar">
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
            </span>
            </button>
            </div>
            <div class="collapse navbar-collapse">
            <?php wp_nav_menu( array(
                     'menu'              => 'left',
                     'theme_location'    => 'left',
                     'depth'             => 2,                      
                     'menu_class'        => 'nav navbar-nav',
                     'fallback_cb'       => 
 'wp_bootstrap_navwalker::fallback',
                     'walker'            => new wp_bootstrap_navwalker())
                  ); ?> 

            <?php wp_nav_menu( array(
                     'menu'              => 'right',
                     'theme_location'    => 'right',
                     'depth'             => 2,                      
                     'menu_class'        => 'nav navbar-nav navbar-right',
                     'fallback_cb'       => 
 'wp_bootstrap_navwalker::fallback',
                     'walker'            => new wp_bootstrap_navwalker())
                  ); ?>                   
            </div>
        </div>
        </div>
    </div>  
Share Improve this question edited Oct 30, 2018 at 2:33 Natasha Curran asked Oct 30, 2018 at 1:40 Natasha CurranNatasha Curran 12 bronze badges 4
  • Hi Natasha, We need a lot more info than that to be able to help. Header files are different for every theme. Which theme is it that you're using? Can you just restore from a back up or re-download the theme? What does the site look like, what is "screwed up"? – rudtek Commented Oct 30, 2018 at 2:12
  • The website isn't being responsive and there are now widgets missing and fonts not displaying correctly. The main banner image is now way too big and the logo is also as big as the page when it should be very small. The theme is also custom - I have been given a pre-made site to edit and add in the Facebook Pixel function. – Natasha Curran Commented Oct 30, 2018 at 2:24
  • I don't see your code for the pixel. To be clear...you should be trying to put it in the head tag, NOT the header tags. – rudtek Commented Oct 30, 2018 at 3:00
  • I didn't include the code because when I pasted it, it didn't appear as code - it translated differently and was very strange. I've been inserting the code inbetween the <head></head> tags, which is what I mean by header tags. – Natasha Curran Commented Oct 30, 2018 at 3:13
Add a comment  | 

1 Answer 1

Reset to default 0

Solved - the code within the css.php was the problem.

The instructions I was given asked me to install a plugin called Insert Headers and Footers, but when I entered the Facebook plugin code it also inserted the entire header.php file code into the style.css file - creating a double of the header code.

This messed up the appearance of my site.

Thanks!

Post a comment

comment list (0)

  1. No comments so far