Custom Field Template
[resolved] hide if empty when using shortcodes? (2 posts)

  1. aptharsia
    Posted 2 years ago #

    I use the shortcode format for the layout of my post data. Part of it looks like this:

    Sometimes the maps field is left empty but because I have a style applied to the li there is a border at the bottom, like this: <a href="http://www.oldhousedreams.com/2010/06/10/1639-cape-cod-sandwich-ma">link</a>, see the extra line under 'References'?

    Is there a way to hide the entire line of
    when that field is left blank?


  2. aptharsia
    Posted 2 years ago #

    If anyone else is curious...

    global $post;
    $bathrooms = get_post_meta($post->ID, 'bathrooms', true);
    if ( !empty($bathrooms) ) { echo '<li>Baths: [bathrooms]</li> ' ; }

    Of course, change the word bathrooms to whatever value you have, but it worked for me.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Custom Field Template
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.