Can I use “is_page_template” to create different background images?
-
I’m helping my mom put up a blog/website for her garden club.
https://www.newarkohiogardenclub.org
There are 3 background images they would like available for different pages of the website portion to be added later as it develops. I am trying to create 3 page templates so that they can choose any of the backgrounds from the admin add a page panel.I found this thread and used the code as a basis to try and incorporate the is_page_template tags.
https://www.ads-software.com/support/topic/329144?replies=22<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php if (is_page_template (‘page_maroon.php’) ):
// page 1 ?>
<style type=”text/css”>
body {background-color:#000;background-image:url(/images/bg_maroon.jpg);background-repeat:no-repeat;}
</style>
<?php elseif (is_page_template (‘page_green.php’) ):
// page 2?>
<style type=”text/css”>
body {background-color:#000;background-image:url(/images/bg_green.jpg);background-repeat:no-repeat;}
</style>
<?php endif; // end the if, no images for other other categories ?>I tried adding the code to the header.php and the page.php, but neither worked. I get an error message that refers me to a line # that doesn’t exist in my file. I do not have a lot of CSS experience, so I’m not sure if the code is the problem or if I put it in the wrong place, etc.
All help appreciated. Thanks.
- The topic ‘Can I use “is_page_template” to create different background images?’ is closed to new replies.