samedi 24 octobre 2015

Check wordpress post for specific HTML tag . Else show post thumbnail

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!

Aucun commentaire:

Enregistrer un commentaire