Wednesday, 22 January 2014

How To Check If Post Has Gallery

In WordPress there is default gallery, i guess most of us don't use because we have awesome plugin called nggallery. But in order to check if a post has gallery or not,we have to add this in wordpress loop.


if (strpos($post->post_content,'[gallery') === false){
  echo 'no gallery';
}else{
  echo 'has gallery';
}

1 comment:

  1. Amazing Tut. Thanks for great sharing with easy tips & tricks.

    http://pashtorung.com

    ReplyDelete