• Hello,

    Inside my loop, I’d like to hide (or not call) a button (or a text) if the customfield is empty.

    Here is my code :

    <div class="blog-text"><?php the_content(); ?>
    <span class="rsTmb">fr</span>
    </div>
    <div class="blog-text"><?php echo get_post_meta($post->ID, 'anglais', true); ?>
    <span class="rsTmb">en</span>
    </div>
    <div class="blog-text"><?php echo get_post_meta($post->ID, 'espagnol', true); ?>
    <span class="rsTmb">es</span>
    </div>

    Thank you !

Viewing 1 replies (of 1 total)
  • Thread Starter adrienquelet

    (@adrienquelet)

    Found it ! Sorry !

    <div class="blog-text"><?php if( empty($post->post_content) ) {} else { echo '<span class="rsTmb">fr</span>'; the_content();} ?></div>
    <div class="blog-text"><?php if( empty($post->anglais) ) {} else { echo '<span class="rsTmb">en</span>'; echo get_post_meta($post->ID, 'anglais', true);} ?></div>
    <div class="blog-text"><?php if( empty($post->espagnol) ) {} else { echo '<span class="rsTmb">es</span>'; echo get_post_meta($post->ID, 'espagnol', true);} ?></div>
Viewing 1 replies (of 1 total)
  • The topic ‘If customfield is empty hide my button’ is closed to new replies.