WordPress.org

Ready to get started?Download WordPress

Forums

Custom field PHP pulling data from incorrect post (1 post)

  1. Preston
    Member
    Posted 3 years ago #

    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/. 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!

Topic Closed

This topic has been closed to new replies.

About this Topic