can this be made to an if else statement
-
Can this:
<?php if ( in_category(9)) { ?> <img src="<?php bloginfo('template_directory'); ?>/images/brose1.jpg" alt="test system image" /> <?php } ?> <?php if ( in_category(8)) { ?> <img src="<?php bloginfo('template_directory'); ?>/images/automation.jpg" alt="test system image" /> <?php } ?>
be made to an if / else?
I was using this:
<?php if (in_category(9)) { echo "<p>we are in category automation</p>"; } elseif (in_category(8)) { echo "<p>we are in category test</p>"; } else { echo "<p>this is anything else</p>"; } // That's all, folks! ?>
but putting in a image instead of text (with or without the “echo”) makes the rest of the page go blank everywhere.
Would like if/else so that I can have a fall back for any page or post without a category.
Or perhaps the first example could have a line of the php that means “if not in any category, display this image”?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘can this be made to an if else statement’ is closed to new replies.