WordPress.org

Ready to get started?Download WordPress

Forums

Book Lite
[resolved] [Book Lite] Featured Image as Header Image in Posts (7 posts)

  1. projectperception
    Member
    Posted 1 year ago #

    Hi there,

    I'm trying to get rid of the Featured Image showing up as the Header Image of Posts. I'll be using the Featured Image in the content of the post, but I would like the Header to be the same as the home page and across all Posts. Let me know if that doesn't make sense.

    Thanks

    http://wordpress.org/extend/themes/book-lite/

  2. projectperception
    Member
    Posted 1 year ago #

    So I'm an idiot. I didn't even see the custom-header.php template. I was able to remove it from there just fine.

  3. Chandra M
    Member
    Theme Author

    Posted 1 year ago #

    Great. If you could post what code you removed, that might help other users in future. :)

    Thank you for liking and using Book Lite. :)

  4. projectperception
    Member
    Posted 1 year ago #

    This is under the "book_header_style()" function. I just took out all of it since I'm not using any header image at all.

    <?php
    		if( is_single() ) :
    
    			if( has_post_thumbnail() ) : 
    
    				$featured_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'featured');
    				$header_image = "background: url(" . $featured_image_url[0] . ") center 0 no-repeat; background-attachment: fixed;";
    				$textcolor = "#fff";
    				$background = "url( ". get_template_directory_uri() ."/images/nav-bg.png)";
    				$libackground = "url( ". get_template_directory_uri() ."/images/diamond-white.png)";
    				$bgcolor = "#111";
    				$height = "500px";
    				$paddingbot = "0";
    
    			else :
    
    				$header_image = "";
    				$textcolor = "#000";
    				$libackground = "url( ". get_template_directory_uri() ."/images/diamond.png)";
    				$bgcolor = "none";
    				$height = "auto";
    				$background = "none";
    				$paddingbot = "auto";
    
    			endif;
    			?>
    			<?php if( has_post_thumbnail() ) : ?>
    			hgroup {
    				position: absolute;
    				bottom: 50px;
    				width: 100%;
    			}
    			<?php endif; ?>
    			#masthead {
    				<?php echo $header_image; ?>
    				margin-top: 0;
    				padding-bottom: <?php echo $paddingbot; ?>;
    				max-width: 100%;
    				height: <?php echo $height; ?>;
    				position: relative;
    				background-color: <?php echo $bgcolor; ?>;
    			}
    			.admin-bar.custom-header #masthead {
    				background-position: center 28px;
    			}
    			#page {
    				max-width: 100%;
    			}
    			#main, #colophon {
    				max-width: 750px;
    				margin: 0 auto;
    			}
    			.main-navigation {
    				background: <?php echo $background; ?>;
    			}
    			.main-navigation ul a {
    				color: <?php echo $textcolor; ?>;
    			}
    			.home .main-navigation ul li, .main-navigation ul li {
    				background: <?php echo $libackground; ?> 0 24px no-repeat;
    			}
    			.main-navigation ul li:first-child {
    				background: none;
    			}
    			.site-title a {
    				color: <?php echo $textcolor; ?>;
    			}			
    
    		<?php
    
    		else :
    
    			$header_image = get_header_image();
    
    			if ( ! empty( $header_image ) ) : 
    
    				$textcolor = "#ccc";
    				$background = "url( ". get_template_directory_uri() ."/images/nav-bg.png)";
    				$libackground = "url( ". get_template_directory_uri() ."/images/diamond-white.png)";
    
    			 ?>
    			#masthead {
    				background: url( <?php echo esc_url( $header_image ); ?> ) center 0 no-repeat;
    				margin-top: 0;
    				padding-bottom: 0;
    				max-width: 100%;
    				height: <?php echo get_custom_header()->height; ?>px;
    				position: relative;
    				background-attachment: fixed;
    			}
    			hgroup {
    				position: absolute;
    				bottom: 50px;
    				width: 100%;
    			}
    			.site-title {
    				max-width: 750px;
    				margin: auto;
    			}
    			.site-description {
    				max-width: 525px;
    			}
    			#page {
    				max-width: 100%;
    			}
    			#main, #colophon {
    				max-width: 750px;
    				margin: 0 auto;
    			}
    			.main-navigation {
    				background: <?php echo $background; ?>
    			}
    			.main-navigation ul a {
    				color: <?php echo $textcolor; ?>
    			}
    			.home .main-navigation ul li, .main-navigation ul li {
    				background: <?php echo $libackground; ?> 0 24px no-repeat ;
    			}
    			.main-navigation ul li:first-child {
    				background: none;
    			}
    
    		<?php endif; ?>
    	<?php endif; ?>
  5. zoltandragon
    Member
    Posted 1 year ago #

    Hi,

    My problem is that if I remove the above code, no header appears whatsoever - not even on the main page. How can I solve this problem? So the aim is to have the set header image for all pages and posts.

    Thank you

  6. Andrew Nevins
    Spam zapper & Volunteer Moderator
    Posted 1 year ago #

    This thread has been marked resolved, Zoltanddragon. Create your own thread if you require support on your own issue.

  7. zoltandragon
    Member
    Posted 1 year ago #

    sorry, posting a new topic,

    cheers

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic