Echoing div when post meta has content
-
Hi all,
I need to wrap my post meta content in a div with top and bottom borders (that are images). I have the code (CODE 1) but it doesn’t display any post meta at all whereas the second bit of code (CODE 2) does but when the custom meta is empty it leaves the border images on page
CODE 1
<?php $meta = get_post_meta( $post->ID, 'rg_wp_editor_sample', true ); if (!empty($post_meta)) { ?> <img src="<?php echo get_stylesheet_directory_uri() ?>/images/bg-acc-top.png" style="margin: 0px 0 -10px 0;"/> <div id="accordion"> <?php echo isset($meta['es']) ? apply_filters('the_content', $meta['es']) : 'no Meta Box meta saved'; ?> </div> <img src="<?php echo get_stylesheet_directory_uri() ?>/images/bg-acc-bottom.png" style="margin: 0px 0 20px 0;"/> <?php }?>
CODE 2
<img src="<?php echo get_stylesheet_directory_uri() ?>/images/bg-acc-top.png" style="margin: 0px 0 -10px 0;"/> <div id="accordion"> <?php $meta = get_post_meta( $post->ID, 'rg_wp_editor_sample', true ); echo isset($meta['es']) ? apply_filters('the_content', $meta['es']) : 'no Meta Box meta saved'; ?> </div> <img src="<?php echo get_stylesheet_directory_uri() ?>/images/bg-acc-bottom.png" style="margin: 0px 0 20px 0;"/>
Any ideas how to echo the whole Div including images only when the custom meta contains information in the back end?
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘Echoing div when post meta has content’ is closed to new replies.