Title: Custom Field php
Last modified: August 18, 2016

---

# Custom Field php

 *  Resolved [ff4500](https://wordpress.org/support/users/ff4500/)
 * (@ff4500)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/custom-field-php/)
 * I’m trying to get custom fields working with a php call in the loop. Here’s the
   code that I currently have, but I know isn’t working. The idea is that if there’s
   an image listed in the custom field in an entry, it will display on the post.
   If not, nothing prints. Here’ the code:
 *     ```
       <?php //get article_image (custom field) ?>
       <?php $image = get_post_meta($post->ID, 'article_image', true); ?>
       ```
   
 * And the code for the entry:
 * `<?php if ($image) { print '<img class="article_image" src="<?php echo $image;?
   >"><br /><br />'; } ?>`
 * The only problem is that it doesn’t actually print out the image url, the php
   echo call is always still in the code as not being parsed. Since I don’t know
   a whole lot about php, this is stumping me. Anyone care to take a gander?

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

 *  Thread Starter [ff4500](https://wordpress.org/support/users/ff4500/)
 * (@ff4500)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/custom-field-php/#post-646109)
 * btw – it’s inspired by [this page](http://www.webdesignerwall.com/tutorials/wordpress-theme-hacks/)
 *  Thread Starter [ff4500](https://wordpress.org/support/users/ff4500/)
 * (@ff4500)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/custom-field-php/#post-646114)
 * fixed it using this code (which is sort of clunky):
 * `<?php if ($image) { echo '<p><img class="article_image" src="'; } ?><?php echo
   $image; ?><?php if ($image) { echo '"></p>'; } ?>`

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

The topic ‘Custom Field php’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 2 replies
 * 1 participant
 * Last reply from: [ff4500](https://wordpress.org/support/users/ff4500/)
 * Last activity: [18 years, 7 months ago](https://wordpress.org/support/topic/custom-field-php/#post-646114)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
