How to change the header background or image in header file
-
HI.. this is the perfect code to change the images in the header for different pages
[ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]
<?php if(is_home()|| is_front_page()) { $image='your_image.jpg'; } else { $image='another_image.jpg'; } echo '<img src="'.get_bloginfo('template_url').'/images/'.$image.'" alt="" />'; ?>
and this is the perfect code to change the background image of the div
<?php if(is_home() || is_front_page()) { ?> <style type="text/css"> .header_image { background-image:url(<?php echo get_template_directory_uri(); ?>/images/Airport_Taxi_Oakville.jpg);background-repeat:no-repeat; } </style> <?php } else { ?> <style type="text/css"> .header_image {background-image:url(<?php echo get_template_directory_uri(); ?>/images/inside_img1.jpg);background-repeat:no-repeat;} </style> <?php } ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to change the header background or image in header file’ is closed to new replies.