Title: Custom Fields &#8211; What&#8217;s wrong with my code?
Last modified: August 19, 2016

---

# Custom Fields – What’s wrong with my code?

 *  [Emily1](https://wordpress.org/support/users/emily1/)
 * (@emily1)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/custom-fields-whats-wrong-with-my-code/)
 * I have a custom field that contains an address for each post, but I can’t figure
   out how to get it to show up. I want it to appear at the end of each post, if
   that post has a value for address. I have Thesis, so I usually use Open Hook.
   If it has to be placed somewhere else, where does it go?
 * This is what I’ve tried so far:
 * add_action(‘thesis_hook_after_post’, ‘address’);
 * I also tried some variations of these:
 * [Get Post Custom Values](http://codex.wordpress.org/Function_Reference/get_post_custom_values)
 * <?php
 *  $address_values = get_post_custom_values(‘address’);
    foreach ( $address_values
   as $key => $value ) { echo “$key => $value (‘address’)”; }
 * ?>
 * [Get_Post_Custom](http://codex.wordpress.org/Function_Reference/get_post_custom)
   
   <?php
 *  $custom_fields = get_post_custom(0);
    $address = $custom_fields[‘address’]; 
   foreach ( $address as $key => $value ) echo $key . ” => ” . $value . “”;
 * ?>
 * Is there another line I need to add somewhere to make these work?

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/custom-fields-whats-wrong-with-my-code/#post-1238059)
 * [http://codex.wordpress.org/Using_Custom_Fields](http://codex.wordpress.org/Using_Custom_Fields)
 *  [doc4](https://wordpress.org/support/users/doc4/)
 * (@doc4)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/custom-fields-whats-wrong-with-my-code/#post-1238206)
 * Emily1,
 * Hopefully I am reading this correctly, but try this. Place the following code
   before the <?php endwhile; ?> tag.
 * `<?php echo get_post_meta($post->ID, 'address', $single=true) ?>`

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

The topic ‘Custom Fields – What’s wrong with my code?’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [doc4](https://wordpress.org/support/users/doc4/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/custom-fields-whats-wrong-with-my-code/#post-1238206)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
