• <?php
        	$dl = get_post_meta($post->ID, 'DL', true);
        	$demo = get_post_meta($post->ID, 'Demo', true);
    
       	 if($dl != '' || $demo != '') {
        	// there is at least one image
        	?>
    
    <?php if($dl != '') : ?>
        <!-- code for $dl here -->
    <h3><a href="<?php echo get_post_meta($post->ID, 'DL', true); ?>">Download</a></h3>
    <?php endif; ?>
    
    <?php if($demo != '') : ?>
    <!-- code for $demo here-->
    <h3><a href="<?php echo get_post_meta($post->ID, 'Demo', true); ?>">View Demo</a></h3>
    <?php endif; ?>

    I am trying to add this code on the bottom of my post. I want to display the code if they have atleast one custom field.

The topic ‘Custom Field’ is closed to new replies.