WordPress tip: check if a post has a gallery

Simply paste the function below into your functions.php file:

 function hasgallery(){     global $  post;     return (strpos($  post->post_content,'[gallery') !== false); }

Once done, you can use it to detect if a post has a gallery.

Thanks to WordPress Stackexchange for the cool tip!


WpRecipes.com

Web Design

checkgallerypostWordPress

Leave a Reply

Your email address will not be published. Required fields are marked *