I'm trying to use PHP to output different HTML for an image slider dependent on the body's page id of a wordpress site
I've tried the below, but being a newbie to PHP, i seem to be getting in a bit of a pickle instead. It just needs to be simple - I can do it via CSS however I'd rather not have all the images loading only to display a select few of them. I'd also rather not use a plugin if possible.
Any pointers would be greatly appreciated.
Thank you
<?php if($id == "page-id-19") {
?>
<div class="imageSlider"><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image2.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image3.jpg" alt="" /></div>
<?php
}
elseif ($id == "page-id-23") {
?>
<div class="imageSlider"><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image4.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image5.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image6.jpg" alt="" /></div>
<?php
}
?>
**UPDATE****
I realised that the id was actually a class.
eg. "body class="page page-id-19 page-template page-template-inner-page-php"
However, when using the suggested solution below, it just doesn't doesn't output any HTML at all to the page... it's being called to the template page via an include -
<?php
switch($class){
case "page-id-19":
?>
<div class="imageSlider"><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image2.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image3.jpg" alt="" /></div>
<?php
break;
case "page-id-23":
?>
<div class="imageSlider"><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image4.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image5.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image6.jpg" alt="" /></div>
<?php
break;
}
?>