I guess this question must have been asked here before, but i couldn't find the topic so bear with me.
I'm trying to achieve an if/else statement in PHP to find a specific HTML tag with a certain classname. If this HTML tag is found i want it to display the HTML tag otherwise if not found, i want it to show the post thumbnail.
All this needs to be done in a wordpress template (single.php).
So i have this:
if (strpos($post->post_content, ('img[.ngg_displayed_gallery]') === false)){
$gallery = false;
the_post_thumbnail('full');
echo do_shortcode('[shareaholic app="share_buttons" id="390155"]');
}
else{
echo ('img[.ngg_displayed_gallery]');
echo do_shortcode('[shareaholic app="share_buttons" id="390155"]');
}
I'm pretty sure i screwed this code up so please help me. I'm very bad with PHP ;)
Thanks for the help! Edit:
Ok.. i'll try to be more clear: When someone edits a wordpress post and adds a Nextgen Gallery in the content editor there is this HTML string:
<img class="ngg_displayed_gallery mceItem" src=“../nextgen-attach_to_post/preview/id--1443" alt="" data-mce-placeholder="1" />
So basically i want to code something like this: When this HTML IMG string appears in the content field, show that INSTEAD of the post thumbnail (featured image).. If that HTML IMG string is NOT in the content field, show the post thumbnail (featured image).
img[.ngg_displayed_gallery]is a selector.<img class='...'>is a html tag. - Kivylius