Title: Clean up header.php
Last modified: August 20, 2016

---

# Clean up header.php

 *  [Johnny Bravo](https://wordpress.org/support/users/herbiehysteria/)
 * (@herbiehysteria)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/clean-up-headerphp/)
 * Hi guys, my blog has been online since 2008 and I’ve never really done a ‘spring
   clean’ of my header.php, i understand there may be redundant code in there, particularly
   FB opengraph tags (which I want to totally eradicate from my header.php so I 
   can put them in my functions.php instead)
 * Also, any redundant javascript too, and it looks like i have declared my favicon
   TWICE.
 * my header.php
 *     ```
       <?php
       /**
        * @package WordPress
        * @subpackage Default_Theme
        */
       ?>
       <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
       <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:og="http://ogp.me/ns#"
       xmlns:fb="https://www.facebook.com/2008/fbml"
       dir="ltr" lang="en-US">
   
       <head profile="http://gmpg.org/xfn/11">
       <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
   
       <title><?php wp_title('«', true, 'right'); ?> <?php bloginfo('name'); ?></title>
   
       <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
       <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
       <link rel="icon" href="<?php bloginfo('siteurl'); ?>/favicon.ico" type="image/x-icon" />
       <link rel="shortcut icon" href="<?php bloginfo('template_directory'); ?>/favicon.ico" type="image/x-icon" />
       <!--[if IE 6]>
       <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/iestyle.css" />
       <![endif]-->
       <style type="text/css" media="screen">
   
       <?php
       global $post;
       $current_page_id = $post->ID;
       // Checks to see whether it needs a sidebar or not
       if ( empty($withcomments) && !is_single() ) {
       ?>
       	#page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg-<?php bloginfo('text_direction'); ?>.jpg") repeat-y top; border: none; }
       <?php } else { /* No sidebar */?>
       	#page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; }
       <?php } ?>
       <?php if ( $current_page_id == 2748 ){?>
       	#menu-item-2757 a {
       		background: url(http://www.artbyherbie.com/wp-content/themes/indezinerpaperwall/images/menu_link_bg.gif) repeat-x center;
       		color: #64431E;
       	}
       <?php } ?>
       </style>
   
       <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
   
       <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
       <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
       <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
       <meta property="og:title" content="<?php the_title(); ?>"/>
       <meta property="og:type" content="<?php
         if (is_singular()) { echo "article"; } else { echo "website";}
       ?>"/>
       <script type="text/javascript">
         (function() {
           var cx = '017502216997493018940:WMX205779490';
           var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true;
           gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
               '//www.google.co.uk/cse/cse.js?cx=' + cx;
           var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);
         })();
       </script>
       <meta property="fb:app_id" content="157766117692061" />
       <meta property="og:title" content="<?php the_title(); ?>"/>
       <meta property="og:url" content="<?php the_permalink(); ?>"/>
       <meta property="og:image" content="<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '', '' ); echo $src[0];
       ?>"/>
       <meta property="og:type" content="<?php  if (is_single() || is_page()) { echo "article"; } else { echo "website";}?>"/>
       <meta property="og:site_name" content="<?php bloginfo('name'); ?>"/>
       <?php wp_head(); ?>
       </head>
       <body <?php body_class(); ?>>
       <div id="fb-root">
       <script type="text/javascript">(function(d, s, id) {
         var js, fjs = d.getElementsByTagName(s)[0];
         if (d.getElementById(id)) return;
         js = d.createElement(s); js.id = id;
         js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=395575387176119";
         fjs.parentNode.insertBefore(js, fjs);
       }(document, 'script', 'facebook-jssdk'));</script></div>
       <div id="main_container">
   
       <div id="header" role="banner">
   
       	       	<div class="logo">
   
                   </div>
   
       </div>
   
       <div class="center_content">
       	<div class="center_content_top">
           	<div class="center_content_bottom">
   
       		<?php
       		function do_the_menu (){
       			wp_page_menu('show_home=1&exclude=6,8, 10, 12, 14, 16, 32, 73, 75, 385, 389, 392, 398, 400, 404, 407, 509, 620, 651, 747, 765, 1037, 1038, 1039, 1040, 1112, 1644, 1826, 2544&menu_class=menu');
       		}
       		//first check if wp_nav_menu has been declared
       		if (function_exists('wp_nav_menu')){
       			//if it has been declared then use it
       			wp_nav_menu( array( 'sort_column' => 'menu_order',
       								'theme_location' => 'primary',
       								'menu' => 'main',
       								'menu_class' => 'sf-menu',
       								'fallback_cb' => 'do_the_menu',
       								'container_class' => 'menu'
       							  )
       						);
       		}else{
       			//if wp_nav_menu doesnt exist we use wp_page_menu
       			do_the_menu();
       		}
       		?>
       ```
   
 * my blog: [http://artbyherbie.com](http://artbyherbie.com)

The topic ‘Clean up header.php’ is closed to new replies.

## Tags

 * [header.php](https://wordpress.org/support/topic-tag/header-php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Johnny Bravo](https://wordpress.org/support/users/herbiehysteria/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/clean-up-headerphp/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
