Support » Plugins and Hacks » Need help with PHP for get_post_meta

Viewing 2 replies - 1 through 2 (of 2 total)
  • Eric,
    This is what I’m thinking would work. Just check if either keys exist, then start the definition list. There might be a more elegant solution though if anyone else wants to chime in.

    <?php if(get_post_meta($post->ID, "Required", true) || get_post_meta($post->ID, "Preferred", true)): ?>
    
    <dl class="skills">
    <!-- Get Required -->
    <?php if(get_post_meta($post->ID, "Required", true)): ?>
    <dt>Required:</dt>
    <dd class="required"><?php $key="Required"; echo get_post_meta($post->ID, $key, true); ?></dd>
    <?php endif; ?>
    <!-- End Required -->
    <!-- Get Preferred -->
    <?php if(get_post_meta($post->ID, "Preferred", true)): ?>
    <dt>Preferred:</dt>
    <dd class="preferred"><?php $key="Preferred"; echo get_post_meta($post->ID, $key, true); ?></dd>
    <?php endif; ?>
    <!-- End Preferred -->
    </dl>
    
    <?php endif; ?>
    Eric Amundson

    (@sewmyheadon)

    Volunteer Moderator

    Perfect, Sean, that did it.

    I was so close, but fudging the syntax.

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need help with PHP for get_post_meta’ is closed to new replies.