JCHASE11
JCHASE11

Reputation: 3941

converting html into php conditional statement

I am using a wordpress plugin that requires the following code in my template:

<li><a href="#"><?php if (class_exists('MultiPostThumbnails')
                    && MultiPostThumbnails::has_post_thumbnail('shanti', 'two-image')) : MultiPostThumbnails::the_post_thumbnail('shanti', 'two-image', NULL,  'big'); 
                endif; ?></a></li>

Basically, it says "if the MultiPost Thumbnails class exists, then display the 'big' image." Im not too great with PHP, but I would like to include the <li><a href="#"> within the conditional statement. Reason is because if there is no image to spit out, I dont want a blank <li> to be displayed. Any idea how to rewrite this code to include the <li>/<a> in the conditional?

Thanks

Upvotes: 1

Views: 330

Answers (1)

Celmaun
Celmaun

Reputation: 24752

Try advanced escaping:

<?php if (class_exists('MultiPostThumbnails')
                && MultiPostThumbnails::has_post_thumbnail('shanti', 'two-image')): ?>
<li><a href="#">
    <?php MultiPostThumbnails::the_post_thumbnail('shanti', 'two-image', NULL,  'big'); ?>
</a></li> 

<?php endif; ?>

Upvotes: 1

Related Questions