0

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>  
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
    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. 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
    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. Oct 30, 2018 at 3:13

1 Answer 1

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.