Daryl Glass
Member
Posted 1 year ago #
Hello
I have a simple if/else condition that I just cant seem to get right. I have it half working in that all the pages other than those specified as is_page are displaying correctly ie they call gallery.php and not the image but the pages that are specified as is_page display both the image and gallery.php where they should only be displaying the image. Please help.
Here is my code:
<?php
if (is_page('apparel')) { echo '<img src="http://website/featured/image_apparel.jpg">'; }
if (is_page('automotive')) { echo '<img src="http://website/featured/image_car.jpg">'; }
else include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php'); }
?>
Thanks.
try to use if/elseif/else;
example using your code:
if (is_page('apparel')) { echo '<img src="http://website/featured/image_apparel.jpg">'; }
elseif (is_page('automotive')) { echo '<img src="http://website/featured/image_car.jpg">'; }
else include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php'); }
Try giving this a go...
<?php if (is_page( 'apparel' )) {
echo '<img src="http://website/featured/image_car.jpg" />';
} elseif (is_page( 'automotive' )) {
echo '<img src="http://website/featured/image_car.jpg" />';
} else {
include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php');
} ?>
Sorry alchymyth, forgot to refresh my page after I got back with a cup of coffee. I didn't see you had already replied. :)
Daryl Glass
Member
Posted 1 year ago #
Thank guys for your speedy response, I will give it a try and let you know.
@theApe
no problem - I do this a lot myself :-)