Advertisement
alchymyth

header.php custom header twenty twelve

Jul 10th, 2013
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.52 KB | None | 0 0
  1. <?php
  2. /**
  3.  * The Header for our theme.
  4.  *
  5.  * Displays all of the <head> section and everything up till <div id="main">
  6.  *
  7.  * @package WordPress
  8.  * @subpackage Twenty_Twelve
  9.  * @since Twenty Twelve 1.0
  10.  */
  11. ?><!DOCTYPE html>
  12. <!--[if IE 7]>
  13. <html class="ie ie7" <?php language_attributes(); ?>>
  14. <![endif]-->
  15. <!--[if IE 8]>
  16. <html class="ie ie8" <?php language_attributes(); ?>>
  17. <![endif]-->
  18. <!--[if !(IE 7) | !(IE 8)  ]><!-->
  19. <html <?php language_attributes(); ?>>
  20. <!--<![endif]-->
  21. <head>
  22. <meta charset="<?php bloginfo( 'charset' ); ?>" />
  23. <meta name="viewport" content="width=device-width" />
  24. <title><?php wp_title( '|', true, 'right' ); ?></title>
  25. <link rel="profile" href="http://gmpg.org/xfn/11" />
  26. <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
  27. <?php // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?>
  28. <!--[if lt IE 9]>
  29. <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
  30. <![endif]-->
  31. <?php wp_head(); ?>
  32. </head>
  33.  
  34. <body <?php body_class(); ?>>
  35. <div id="page" class="hfeed site">
  36.     <header id="masthead" class="site-header" role="banner">
  37.         <hgroup>
  38.             <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
  39.             <h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
  40.         </hgroup>
  41.  
  42.         <nav id="site-navigation" class="main-navigation" role="navigation">
  43.             <h3 class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></h3>
  44.             <a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a>
  45.             <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
  46.         </nav><!-- #site-navigation -->
  47.  
  48. <?php
  49.                 // Check to see if the header image has been removed
  50.                 $header_image = get_header_image();
  51.                 if ( $header_image ) :
  52.                     // Compatibility with versions of WordPress prior to 3.4.
  53.                     if ( function_exists( 'get_custom_header' ) ) {
  54.                         // We need to figure out what the minimum width should be for our featured image.
  55.                         // This result would be the suggested width if the theme were to implement flexible widths.
  56.                         $header_image_width = get_theme_support( 'custom-header', 'width' );
  57.                     } else {
  58.                         $header_image_width = HEADER_IMAGE_WIDTH;
  59.                     }
  60.                     ?>
  61.             <a href="<?php echo esc_url( home_url( '/' ) ); ?>">
  62.                 <?php
  63.                     // The header image
  64.                     // Check if this is a post or page, if it has a thumbnail, and if it's a big one
  65.                     if ( is_singular() && has_post_thumbnail( $post->ID ) &&
  66.                             ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) &&
  67.                             $image[1] >= $header_image_width ) :
  68.                         // Houston, we have a new header image!
  69.                         echo get_the_post_thumbnail( $post->ID, 'header-image' ); //EDITED IMAGE SIZE
  70.                     else :
  71.                             $header_image_width  = get_custom_header()->width;
  72.                             $header_image_height = get_custom_header()->height;
  73.                         ?>
  74.                     <img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />
  75.                 <?php endif; // end check for featured image or standard header ?>
  76.             </a>
  77.             <?php endif; // end check for removed header image ?>
  78.            
  79.     </header><!-- #masthead -->
  80.  
  81.     <div id="main" class="wrapper">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement