1

Two questions

  1. I need an updated code for this question

  2. How can I hide the value if there is no value entered?

My value would be a link, and this is my current code

<a href="<?php echo get_post_meta($post->ID, 'mp3_link1', true); ?>" target="_blank">MP3</a>

I need to do this without any plugins.

  • Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, consider taking a look at: How does deleting work? – iBooot Feb 18 at 20:47
1

All you have to do to hide this link is to check, if it's empty:

<?php if ( $link = get_post_meta($post->ID, 'mp3_link1', true) && trim($link) ) : ?>
    <a href="<?php echo esc_attr($link); ?>" target="_blank">MP3</a>
<?php endif; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy