Conditional tag help
-
I’m trying to write some conditional tag code so that I can show different banner images on different pages of a site. I started with this, to show a different header on the “disclaimer” page:
<?php if (is_page("disclaimer")) { echo "<div id="header" style=" background:url('<?php bloginfo('url'); ?>/wp-content/themes/themename/images/top2.jpg') no-repeat bottom; ">"; } else { echo "<div id="header" style=" background:url('<?php bloginfo('url'); ?>/wp-content/themes/themename/images/top.jpg') no-repeat bottom; ">"; } ?>The error message I’m getting is:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/myfoldername/public_html/1/wp-content/themes/themename/header.php on line 31Line 31 is the first of the two “echo” lines, and it does end with a semi-colon, so I’m not sure what I’m doing wrong.
If I get rid of the conditional stuff and just have
<div id="header" style=" background:url('<?php bloginfo('url'); ?>/wp-content/themes/themename/images/top.jpg') no-repeat bottom; ">It works fine but then of course it displays the same header graphic on every page.
myfoldername and themename are replacements of the real names for the purposes of this example. In reality, they are both something else.
Thanks
The topic ‘Conditional tag help’ is closed to new replies.