Support » Theme: Book Lite » [Book Lite] Featured Image as Header Image in Posts

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter projectperception

    (@projectperception)

    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.

    Theme Author Chandra M

    (@nhuja)

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

    Thank you for liking and using Book Lite. 🙂

    Thread Starter projectperception

    (@projectperception)

    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; ?>

    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

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

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

    sorry, posting a new topic,

    cheers

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Book Lite] Featured Image as Header Image in Posts’ is closed to new replies.