WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] display text only when custom field is filled (3 posts)

  1. AndresHolmes
    Member
    Posted 3 years ago #

    Hi,
    I'm using plugin More Fields and have this code in single.php
    zdroj: <a href="<?php echo get_post_meta($post->ID, 'zdroj', true);?>"> <?php echo get_post_meta($post->ID, 'szdroj', true);?> </a>
    I want to display the output only when there is something written in the "zdroj". How can I do it?

  2. vtxyzzy
    Member
    Posted 3 years ago #

    Try this (UNTESTED):

    <?php
    $zdroj = get_post_meta($post->ID, 'zdroj', true);
    if ($zdroj) :
    ?>
    zdroj: <a href="<?php echo $zdroj;?>"> <?php echo get_post_meta($post->ID, 'szdroj', true);?> </a>
    <?php endif; ?>
  3. AndresHolmes
    Member
    Posted 3 years ago #

    it's working, thanks very much

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.