1

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

1 Answer 1

1

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; ?>
Sign up to request clarification or add additional context in comments.

3 Comments

thats it, i will accept your answer in a few minutes. thanks!
Or just use "echo" and be neater.
@Mike Nah this is the style they use in wordpress and is recommended by WP Coding Standards ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.