Title: Adding post Custom Field to content.php
Last modified: August 30, 2016

---

# Adding post Custom Field to content.php

 *  [roptech](https://wordpress.org/support/users/roptech/)
 * (@roptech)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/adding-post-custom-field-to-contentphp/)
 * Hey guys,
 * Is there a way, after adding a Custom Field to a post, to then put the content
   of that Custom Field in to content.php to show on the Category page?
 * I’d basically like to be able to make a Custom Field with:
 * Name: RoR
    Value: /wp-includes/images/ror35.png
 * Then be able to display that Value inside an img tag within the category archive
   page, by adding it to content.php
 * An example, on this link below, next to “June 27th, 2014 by Rock On” I’d like
   to be able to put an image that’s dragged in from the Custom Field for that post.
 * [http://rockonpublishing.co.uk/unsigned-reviews/](http://rockonpublishing.co.uk/unsigned-reviews/)
 * I’ve had a good old look through Google but can’t find what I need to do.
 * Any ideas? I’m using Twenty Thirteen theme.

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

 *  [Chris Huff](https://wordpress.org/support/users/brochris/)
 * (@brochris)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/adding-post-custom-field-to-contentphp/#post-6362633)
 * Try this where you want to display the custom field.
 *     ```
       <?php
           $img = get_post_meta( get_the_ID(), 'RoR', true);
           if( ! empty( $img ) ) {
               echo '<img src="' . $img . '" />';
           }
       ?>
       ```
   
 * Haven’t tested it, but it should work. Let me know.
 *  Thread Starter [roptech](https://wordpress.org/support/users/roptech/)
 * (@roptech)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/adding-post-custom-field-to-contentphp/#post-6362696)
 * Absolutely brilliant, thanks!
 *  Thread Starter [roptech](https://wordpress.org/support/users/roptech/)
 * (@roptech)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/adding-post-custom-field-to-contentphp/#post-6362728)
 * Is it possible to put in place an if statement that says if there is a custom
   field with the name of RoR, then show X?
 * Like:
 * IF {custom field name} exists
 * {content here}
 * ENDIF
 *  Thread Starter [roptech](https://wordpress.org/support/users/roptech/)
 * (@roptech)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/adding-post-custom-field-to-contentphp/#post-6362747)
 * Any clue, anyone?
 *  Thread Starter [roptech](https://wordpress.org/support/users/roptech/)
 * (@roptech)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/adding-post-custom-field-to-contentphp/#post-6362763)
 * I actually managed to figure it out myself from trial/error/looking at other 
   working code.
 * For anyone interested:
 *     ```
       <?php
       $key = 'SCurl';
       $themeta = get_post_meta($post->ID, $key, TRUE);
       ?>
       <?php if($themeta != '') : ?>
       <div class="entry-single-info">
       	<span><strong>Soundcloud:</strong> <a href="http://soundcloud.com<?php $scurl = get_post_meta( get_the_ID(), 'SCurl', true); if( ! empty( $scurl ) ) { echo '' . $scurl . ''; } ?>" target="_blank"><?php $scurl = get_post_meta( get_the_ID(), 'SCurl', true); if( ! empty( $scurl ) ) { echo '' . $scurl . ''; } ?></a></span>
       </div>
   
       <?php else : ?>
   
       <?php endif; ?>
       ```
   
 * This shows, e.g. “Soundcloud: /soundcloudlink (<< that being a link to the soundcloud)
   if the custom field named SCurl exists and has data. There is probably a cleaner
   way to do this, but it works for me 🙂

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

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

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 5 replies
 * 2 participants
 * Last reply from: [roptech](https://wordpress.org/support/users/roptech/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/adding-post-custom-field-to-contentphp/#post-6362763)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
