Ready to get started?Download WordPress


[resolved] Trouble with Custom Fields (please help!) (3 posts)

  1. Alberto
    Posted 2 years ago #

    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):

    $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.


  2. esmi
    Forum Moderator
    Posted 2 years ago #

    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:

    $property_address = get_post_meta($post->ID, 'property_address', true);
    echo '<pre>';
    echo '</pre>';
  3. Alberto
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic