Title: Custom field PHP pulling data from incorrect post
Last modified: August 20, 2016

---

# Custom field PHP pulling data from incorrect post

 *  [Preston](https://wordpress.org/support/users/firebot/)
 * (@firebot)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/custom-field-php-pulling-data-from-incorrect-post/)
 * I have some custom field calls in the sidebar of my post pages which pull data
   from custom fields in the post. I have instances where some custom field calls
   are pulling data from other posts, not from the post that the sidebar is currently
   on. I **think** this is happening after I have blank custom fields, and then 
   try to add data again. Though I haven’t been able to reliably recreate it in 
   any instance.
 * Below is the code in my sidebar that I’m using to call the custom field data:
 *     ```
       <?php
       $sellerphone = get_post_meta($post->ID, 'sellerphone', true);
       $sellermobilephone = get_post_meta($post->ID, 'sellermobilephone', true);
   
       if ( $sellerphone || $selleraddr ) {
          _e('For questions <strong>about the property</strong>, please contact the seller:','language');?><br />
       <?    if ( $sellerphone )
              echo 'Phone: ' . $sellerphone. '<br />';
             if ( $sellermobilephone )
              echo 'Mobile: ' . $sellermobilephone. '<br />';
       ?>
       ```
   
 * The website is being built on this theme: [http://gorillathemes.com/real-agent-wordpress-real-estate-theme/](http://gorillathemes.com/real-agent-wordpress-real-estate-theme/).
   However, the custom fields I’m trying to call I added in myself based on how 
   the rest of the custom fields were being handled in the theme. So if this isn’t
   a WordPress problem, it could very well have something to do with how I edited
   the theme. If that’s the case I’ll take the problem over to their forms.
 * Thanks for the help!

The topic ‘Custom field PHP pulling data from incorrect post’ is closed to new replies.

## Tags

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

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 0 replies
 * 1 participant
 * Last reply from: [Preston](https://wordpress.org/support/users/firebot/)
 * Last activity: [14 years, 9 months ago](https://wordpress.org/support/topic/custom-field-php-pulling-data-from-incorrect-post/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
