Title: Custom Fields If Statement
Last modified: August 19, 2016

---

# Custom Fields If Statement

 *  Resolved [enkayes](https://wordpress.org/support/users/enkayes/)
 * (@enkayes)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/custom-fields-if-statement/)
 * Hey forum,
 * I’m trying to get a statement to check if a custom field exists and if it does,
   output some code.
 * I’m pretty sure the if statement is working properly, but the variable to get
   the path is improperly coded.
 * Am I correct with this? Does anyone see the issue?
 * Thanks!
 * –nks
 *     ```
       <?php
       $key = 'side-bar-video';
       $themeta = get_post_meta($post->ID, $key, TRUE);
       $path1 = TEMPLATEPATH . "/media/videos/" ;
       if($themeta != '') {
       	echo '
       	[kml_flashembed movie="' . $path1 . $themeta .  '" width="313" height="250"]
       	[/kml_flashembed]
   
       	';
   
          }
   
         ?>
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [enkayes](https://wordpress.org/support/users/enkayes/)
 * (@enkayes)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/custom-fields-if-statement/#post-1500104)
 * and just to give more perspective…
 * The custom field ‘side-bar-video’ has a value of *filename*.swf and the path 
   to the file is /wp-content/themes/*my-theme*/media/videos/*filename*.swf
 *  [Mark / t31os](https://wordpress.org/support/users/t31os_/)
 * (@t31os_)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/custom-fields-if-statement/#post-1500122)
 * Try..
 *     ```
       $path1 = get_bloginfo( 'template_directory' ) . "/media/videos/" ;
       ```
   
 *  Thread Starter [enkayes](https://wordpress.org/support/users/enkayes/)
 * (@enkayes)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/custom-fields-if-statement/#post-1500125)
 * win!
 * Thanks so much!
 * I kept trying <?php bloginfo(‘template_url’); ?> but what having issues because
   of the opening and closing php tags. I didn’t even know that function existed.
 * +5 internets to you.
 * –nks

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Custom Fields If Statement’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [enkayes](https://wordpress.org/support/users/enkayes/)
 * Last activity: [16 years, 1 month ago](https://wordpress.org/support/topic/custom-fields-if-statement/#post-1500125)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
