Php if else with html
Any help figuring out why I am getting "else" (T_ELSE) in your code on the line in the code below?
<?php if ( is_category( '3' ) ) ?>
<td class="logo-alts"><a href="/"><img src="<?php bloginfo('template_directory'); ?>/_images/image1.png"></a></td>
<?php if ( is_category( '1096' ) ) ?>
<td class="logo-alts"><a href="/"><img src="<?php bloginfo('template_directory'); ?>/_images/image2.png"></a></td>
<?php if ( is_category( '1437' ) ) ?>
<td class="logo-alts"><a href="/"><img src="<?php bloginfo('template_directory'); ?>/_images/image3.png"></a></td>
<?php if ( is_category( '1150' ) ) ?>
<td class="logo-alts"><a href="/"><img src="<?php bloginfo('template_directory'); ?>/_images/image4.png"></a></td>
<?php if ( is_category( '1138' ) ) ?>
<td class="logo-alts"><a href="/"><img src="<?php bloginfo('template_directory'); ?>/_images/image.png"></a></td>
<?php if ( is_category( '3' ) ) ?>
<td class="logo-alts"><a href="/"><img src="<?php bloginfo('template_directory'); ?>/_images/image5.png"></a></td>
<?php else : ?>
<td class="logo-alts"><a href="/"><img src="<?php bloginfo('template_directory'); ?>/_images/image6.png"></a></td>
<?php endif; ?>
+3
source to share
1 answer
Format your IF statement like this:
<?php if (is_category('3')) : ?>
<td class="logo-alts"><a href="/"><img src="<?php bloginfo('template_directory'); ?>/_images/image.png"></a></td>
<?php elseif (is_category('1096')) : ?>
<td class="logo-alts"><a href="/"><img src="<?php bloginfo('template_directory'); ?>/_images/image.png"></a></td>
<?php elseif (is_category('1437')) : ?>
<td class="logo-alts"><a href="/"><img src="<?php bloginfo('template_directory'); ?>/_images/image.png"></a></td>
<?php elseif (is_category('1150')) : ?>
<td class="logo-alts"><a href="/"><img src="<?php bloginfo('template_directory'); ?>/_images/image.png"></a></td>
<?php elseif (is_category('1138')) : ?>
<td class="logo-alts"><a href="/"><img src="<?php bloginfo('template_directory'); ?>/_images/image.png"></a></td>
<?php elseif (is_category('3')) : ?>
<td class="logo-alts"><a href="/"><img src="<?php bloginfo('template_directory'); ?>/_images/image.png"></a></td>
<?php else : ?>
<td class="logo-alts"><a href="/"><img src="<?php bloginfo('template_directory'); ?>/_images/image.png"></a></td>
<?php endif; ?>
+2
source to share