Reputation: 25
I like to show different logo on two different page but keep the original logo on front page and the rest of the site. So I try with wordpress conditional tag but It doesn't work. Someone can help me?
Thank you.
<?php if ( ! is_front_page() ) {?>
<img class="logo-top" src="image1" alt="image1">
<?php } ?>
<?php elseif ( ! is_page(157) ) {?>
<img class="logo-top" src="image2" alt="image2">
<?php } ?>
<?php elseif ( ! is_page(157) ) {?>
<img class="logo-top" src="image3" alt="image3">
<?php } ?>
<?php else ( ) ) {?>
<img class="logo-top" src="image1" alt="image1">
<?php } ?>
<?php endif; ?>
Upvotes: 0
Views: 447
Reputation: 25
Here the solution I found. Thanks.
<?php
if ( is_front_page() ) {
// Default homepage
echo ('<img class="logo-top" src="image1" alt="image1">');
}
elseif ( is_page( 157 ) ) {
// landingpage1
echo ('<img class="logo-top" src="image2" alt="image2">');
}
elseif ( is_page( 159 ) ) {
// Landingpage2
echo ('<img class="logo-top" src="image3" alt="image3">');
}
else {
// All other page
echo ('<img class="logo-top" src="image1" alt="image1">');
}?>`
Upvotes: 0
Reputation: 12391
The correct syntax is:
<?php if (!is_front_page()) { ?>
<img class="logo-top" src="image1" alt="image1">
<?php } elseif (!is_page(157) ) { ?>
<img class="logo-top" src="image2" alt="image2">
<?php } elseif (!is_page(157) ) { ?> <!-- Why is this the same id? Never will be executed -->
<img class="logo-top" src="image3" alt="image3">
<?php } else { ?>
<img class="logo-top" src="image1" alt="image1">
<?php }
Upvotes: 1
Reputation: 6893
I see two problem.
<?php else ( ) ) {?>
should be <?php else {?>
<?php endif; ?>
.Upvotes: 0