Title: get_post_custom value
Last modified: August 20, 2016

---

# get_post_custom value

 *  Resolved [jasonsweb](https://wordpress.org/support/users/jasonsweb/)
 * (@jasonsweb)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/get_post_custom-value/)
 * Hi,
 * I’m trying to build a staff page for my theme. The staff members can enter their
   social media profiles, like twitter, facebook, etc. In total there are 10 custom
   fields.
 * In my single-staff.php I would like to display all the staff members info.
    At
   the moment I use this code:
 *     ```
       <?php $custom = get_post_custom($post->ID); // Get all custom fields ?>
       <?php if ($custom['staff_twitter'][0] != '') { // Display Twitter ?>
       <a href="http://www.twitter.com/<?php echo $custom['staff_twitter'][0]; ?>">Twitter</a>
       <?php } ?>
       ```
   
 * So the link will only show up, if a staff member entered a twitter url. But when
   a member leaves the twitter field blank, I’m getting this error in WP_Debug mode:
   
   Notice: Undefined index: tw_staff_twitter
 * Is there something I’m doing wrong?
 * Thanks in advance!

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

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/get_post_custom-value/#post-2832980)
 * You can test if the key exists and has a value with this:
 *     ```
       if (isset($custom['staff_twitter'][0]) && $custom['staff_twitter'][0]) {
       // Display Twitter
       }
       ```
   
 * Or use get_post_meta():
 *     ```
       $twitter = get_post_meta($post->ID, 'staff_twitter', true);
       if($twitter != '') {
       // Display Twitter
       }
       ```
   
 *  Thread Starter [jasonsweb](https://wordpress.org/support/users/jasonsweb/)
 * (@jasonsweb)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/get_post_custom-value/#post-2832995)
 * Thanks for the fast reply!
 * I’m going for the first option, so I don’t have to load the custom fields one
   by one.
    It works perfect. Thanks!
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/get_post_custom-value/#post-2833025)
 * You’re welcome. I’m glad you got it resolved.

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

The topic ‘get_post_custom value’ is closed to new replies.

## Tags

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

 * 3 replies
 * 2 participants
 * Last reply from: [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/get_post_custom-value/#post-2833025)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
