WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. aptharsia
    Member
    Posted 1 year ago #

    I use the shortcode format for the layout of my post data. Part of it looks like this:
    `<li>[maps]</li>
    <li>[references]</li>'

    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
    <li>[maps]</li>
    when that field is left blank?

    http://wordpress.org/extend/plugins/custom-field-template/

  2. aptharsia
    Member
    Posted 1 year ago #

    If anyone else is curious...

    <?php
    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

About this Topic

Tags

No tags yet.