Title: Conditional Custom Field
Last modified: August 19, 2016

---

# Conditional Custom Field

 *  [saramac](https://wordpress.org/support/users/saramac/)
 * (@saramac)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/conditional-custom-field/)
 * I want to create a conditional statement to populate an image and link based 
   on the custom tags. I’m not exactly a whiz at PHP so I’ve been muddling through
   it all. Ideally, I’d like to have one custom field called “link-type” with the
   values of “more” or “programs” which would be used for the conditional statement.
   I haven’t figured out how to do that and have instead been trying to use two 
   separate custom fields of “programs” and “more” and have them return a value 
   if the value returns true.
 * This is what I have so far which doesn’t work:
 * <?php if((get_post_meta($post->ID, “programs”, true)) || (get_post_meta($post-
   >ID, “more”, true))) { ?>
 *     ```
       <?php if(get_post_meta($post->ID, "more", true)) ?>
               <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/images/btn-content-learnmore.png" alt="" width="110" height="30" /></a>
   
               <?php if(get_post_meta($post->ID, "programs", true)) ?>
               <a href="<?php echo home_url( '/' ); ?>locations/chesterfield/our-programs/" title="<?php the_title(); ?>"><a href=""<img src="<?php bloginfo('template_directory'); ?>/images/btn-content-viewprograms.png" alt="" width="196" height="30" /></a>
   
               <?php } ?>
       ```
   
 * Any help is GREATLY appreciated.

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

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [page template](https://wordpress.org/support/topic-tag/page-template/)

 * 0 replies
 * 1 participant
 * Last reply from: [saramac](https://wordpress.org/support/users/saramac/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/conditional-custom-field/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
