• Resolved Alberto

    (@ahorihuela)


    Hello Everyone,

    I’ve come to you for help!

    I am having some difficulty displaying content on new custom fields in my posts. Here is the breakdown – I am creating a new custom field in a post and a key = “property_address”. I am then attempting to pull the content in “property_address” by use of the following loop (which I’ve inserted in my single.phptemplate file):

    <?php
    $property_address = get_post_meta($post->ID, 'property_address', true);
    if($property_address != '') {
    echo “Property Address: " . $property_address;
    }
    ?>

    Do you see anything wrong with this function? Unfortunately, the loop is not displaying any of the values under new fields, such as 'property_address'. Yet if I were to reference other custom fields (which have been automatically created by the template I am using or plugins), the loop successfully displays the value.

    I am wondering whether there might be any issues with the code above or if there are any known issues with pooling newly added fields.

    Thanks in advance to everyone for all the help.

    Alberto

Viewing 2 replies - 1 through 2 (of 2 total)
  • I can’t see anything obviously wrong in your code above. Try dumping the contents of get_post_meta to the screen to check what exactly is being pulled:

    <?php
    $property_address = get_post_meta($post->ID, 'property_address', true);
    echo '<pre>';
    print_r($property_address);
    echo '</pre>';
    ?>
    Thread Starter Alberto

    (@ahorihuela)

    Esmi — thanks a lot for your help! I was able to figure it out. I really appreciate your input.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Trouble with Custom Fields (please help!)’ is closed to new replies.