display a div if post has custom field info
-
I need some text to be displayed ONLY is there is a list of photos in a custom field.
I have a custom field called ‘gallery_bts’ that displays a gallery of behind-the-scenes photos. In my php template I have this code:
<?php echo do_shortcode('[gallery type="rectangular" link="file" ids="'.get_post_meta($post->ID, 'gallery_bts', true).'"]'); ?>
Above that gallery I have some text:
<div class="bts"><br> <div class="line"> </div> <h2>Behind the Scenes</h2> <div class="line"> </div><br> </div>
If a post doesn’t have any uploaded behind-the-scenes photos, I don’t need that text to be displayed. Only if there is a list of photos in the gallery_bts custom field, do I need the text to be displayed.
example post with behind-the-scenes photos:
https://beta.fugostudios.com/vanilla-gift-card/example post without behind-the-scenes photos:
https://beta.fugostudios.com/iris-worldwide/
- The topic ‘display a div if post has custom field info’ is closed to new replies.