How to prevent showing a box created using custom fields if there's no custom field sets

Hello everyone.
I created a Download Box using custom fields & styled it. the code is this :

<div class="download-links">
  <ul>
   <?php $cf_var = get_post_meta( $post->ID, 'download', true );
    if( isset($cf_var) && !empty(cf_var) ) : ?>
     <li class="download">
      <a href="<?php echo get_post_meta( $post->ID, 'download', true ); ?>">Download HQ</a>
     </li>
    <?php endif; ?>
  </ul>
</div><!-- end of .download-links -->

There’s two other fields like this & I styled them in styles.css .

The problem is whether the post has custom field assigned, or not, the Download Box is showing.
How can I find out if the post has custom field or not, and then the code run and styles applied ?

thanks.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.