PHP & WP: Render Certain Markup Based on True False Condition

Posted by rob on Stack Overflow See other posts from Stack Overflow or by rob
Published on 2010-05-26T14:39:40Z Indexed on 2010/05/26 14:41 UTC
Read the original article Hit count: 230

Filed under:
|

So, I'm working on a site where on the top of certain pages I'd like to display a static graphic and on some pages I would like to display an scrolling banner.

So far I set up the condition as follows:

<?php 
    $regBanner = true;
    $regBannerURL =  get_bloginfo('stylesheet_directory'); //grabbing WP site URL 
?>

and in my markup:

<div id="banner">
  <?php

if ($regBanner) {
  echo "<img src='"  . $regBannerURL . "/style/images/main_site/home_page/mock_banner.jpg' />";
}

else {
  echo 'Slider!';
}

?>
</div><!-- end banner -->

In my else statement, where I'm echoing 'Slider!' I would like to output the markup for my slider:

  <div id="slider">
    <img src="<?php bloginfo('stylesheet_directory') ?>/style/images/main_site/banners/services_banners/1.jpg" alt="" />
    <img src="<?php bloginfo('stylesheet_directory') ?>/style/images/main_site/banners/services_banners/2.jpg" alt="" />
    <img src="<?php bloginfo('stylesheet_directory') ?>/style/images/main_site/banners/services_banners/3.jpg" alt="" />
        .............
  </div>

My question is how can I throw the div and all those images into my else echo statement? I'm having trouble escaping the quotes and my slider markup isn't rendering.

© Stack Overflow or respective owner

Related posts about php

Related posts about Wordpress