PHP Structuring an if statement inside an if else statement

I have created an if statement inside the “else” of an if/else statement.It works.However the code below the function does not run.When i remove the function the code below the function runs.Could you please help me out.

This code causes the problem:

Read More
<?php $googleplay= get_option('director_googleplay');?>
<?php if($googleplay): ?>
    <a href="<?php print $googleplay; ?>">
       <img src="<?=IMAGES?>/googleplay.png" class=" img-responsive  top-buffer-5"  alt="Image"/>
    </>
<?php endif;;?> 

The php:

<?php  $category_id = get_cat_ID('Category Name'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <?php if ( in_category("1") ) { ?>
       <div class="section"></div>

    <?php } elseif ( in_category("2") ) { ?>
       <div class="section"></div>

  <?php } else { ?>
      <div class="section">
          <?php $googleplay= get_option('director_googleplay');?>
          <?php if($googleplay): ?>
              <a href="<?php print $googleplay; ?>"><img src="<?=IMAGES?>/googleplay.png" class=" img-responsive  top-buffer-5"  alt="Image"/></>
          <?php endif;;?> 
       </div>
    <?php } ?>
<?php endwhile;else: ?>
    <p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>

<div class="section">
    <?php $facebook= get_option('director_facebook');
    <?php if($facebook): ?>
    <a href="<?php print $facebook; ?>"><img src="<?=IMAGES?>/Facebook.png" class=" img-responsive pull-left"alt="Image"/></>
    <?php endif; ?>
</div>

Related posts

Leave a Reply

1 comment

  1. Well, you forgot to close the <a>-Tag: </a>, not </>. However, the Code should still “run”, just display garbage.

    Additionally, php snippets can also be started and ended by the <?-Tag, you have one of those in your code:


    <img src="/googleplay.png" class=" img-responsive top-buffer-5" alt="Image"/>

    should work. Remove <?=IMAGES?> which probably causes the problem. What are you trying to do with <?=IMAGES?>?