Advertisement
Guest User

Custom Header in sidebar-page.php

a guest
Aug 2nd, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. <?php
  2. /**
  3. * Template Name: Sidebar Template
  4. * Description: A Page Template that adds a sidebar to pages
  5. *
  6. * @package WordPress
  7. * @subpackage Twenty_Eleven
  8. * @since Twenty Eleven 1.0
  9. */
  10.  
  11. get_header(); ?>
  12.  
  13. <?php
  14. // Check to see if the header image has been removed
  15. $header_image = get_header_image();
  16. if ( ! empty( $header_image ) ) :
  17. ?>
  18.  
  19. <?php
  20. // The header image
  21. // Check if this is a post or page, if it has a thumbnail, and if it's a big one
  22. if ( is_singular() &&
  23. has_post_thumbnail( $post->ID ) &&
  24. ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( HEADER_IMAGE_WIDTH, HEADER_IMAGE_WIDTH ) ) ) &&
  25. $image[1] >= HEADER_IMAGE_WIDTH ) :
  26. // Houston, we have a new header image!
  27. echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
  28. else : ?>
  29. <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" id="large_image" alt="" />
  30. <?php endif; // end check for featured image or standard header ?>
  31.  
  32. <?php endif; // end check for removed header image ?>
  33.  
  34.  
  35. <?php get_sidebar(); ?>
  36. <div id="primary">
  37. <div id="content" role="main">
  38.  
  39. <?php while ( have_posts() ) : the_post(); ?>
  40.  
  41. <?php get_template_part( 'content', 'page' ); ?>
  42.  
  43.  
  44. <?php endwhile; // end of the loop. ?>
  45.  
  46. </div><!-- #content -->
  47. </div><!-- #primary -->
  48.  
  49. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement