Title: Function using Custom Field content
Last modified: August 19, 2016

---

# Function using Custom Field content

 *  Resolved [artfulalibi](https://wordpress.org/support/users/artfulalibi/)
 * (@artfulalibi)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/function-using-custom-field-content/)
 * Hello. I apologize ahead of time, my PHP is only basic.
 * I am using some custom field data to pass a variable to a function in my theme
   template. However, when I don’t use the custom field, it causes an error in the
   function because it has no data. Is there any way for me to write an if statement
   based on the custom field data, kind like of if function_exists?
 * Here is my code:
 *     ```
       <?php
       	setZoom(3);
               setWidth(400);
               setHeight(350);
       	addAddress(get_meta('building_address'));
       	showMap();
       	?>
       ```
   
 * Basically I want something that says if the key ‘building_address’ has data in
   it, run this function.
 * Thanks everyone!

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/function-using-custom-field-content/#post-763313)
 * You mean something like Kaf’s answer?
    [http://wordpress.org/support/topic/150505?replies=3#post-671912](http://wordpress.org/support/topic/150505?replies=3#post-671912)
 * [Function_Reference/get_post_meta](http://codex.wordpress.org/Function_Reference/get_post_meta)
 *  Thread Starter [artfulalibi](https://wordpress.org/support/users/artfulalibi/)
 * (@artfulalibi)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/function-using-custom-field-content/#post-763322)
 * Hmm. I don’t see how to make that post relevant to this one.
 * The key being passed is going to be a string, how do I test to see if it is empty,
   or has content. I guess that is what I am asking.
 *  Thread Starter [artfulalibi](https://wordpress.org/support/users/artfulalibi/)
 * (@artfulalibi)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/function-using-custom-field-content/#post-763529)
 * O I get it! Thanks Michael.

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

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

## Tags

 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [if](https://wordpress.org/support/topic-tag/if/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [artfulalibi](https://wordpress.org/support/users/artfulalibi/)
 * Last activity: [18 years, 1 month ago](https://wordpress.org/support/topic/function-using-custom-field-content/#post-763529)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
