php - Add element to if else statement. Wordpress -
i have if else statement gives me <img src=""..../>
element result. problem want statement give me result <li><img src=""..../></li>
i wrap if stament around <li>
element loose purpose of im trying do. there way can add <li>
elements inside if statement ?
function
<?php if(class_exists('multipostthumbnails') && multipostthumbnails::has_post_thumbnail('post', 'secondary-image')) { multipostthumbnails::the_post_thumbnail('post', 'secondary-image', null, 'post-secondary-image-thumbnail'); }else { } ?>
result
<img src="..."/>
desired result
<li> <img src="..."/></li>
the source code is
if (class_exists('multipostthumbnails')) { new multipostthumbnails(array( 'label' => 'secondary image', 'id' => 'secondary-image', 'post_type' => 'post' ) ) ;new multipostthumbnails(array( 'label' => 'third image', 'id' => 'third-image', 'post_type' => 'post' ) ); }
instead wrapping <li>
around if statement, can use get_the_post_thumbnail()
instead of the_post_thumbnail()
. function return img tag string not echo it.
you can string manipulation/add tags , echo whenever want.
Comments
Post a Comment