Title: custom fields get_post_meta question
Last modified: August 19, 2016

---

# custom fields get_post_meta question

 *  Resolved [gerrycircus](https://wordpress.org/support/users/gerrycircus/)
 * (@gerrycircus)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/custom-fields-get_post_meta-question/)
 * I am creating a post template in my wordpress.
 * I need to have:
    1/ a dynamic src inside an image – so I can place “artist-image”
   as custom field and the path. This works. 2/ I need to a link underneath that
   contains a website link 3/ pretty much the same as number 2
 * Here’s my PHP – 2 and 3 aren’t working – but number 1 is. What am I doing wrong?
   Any ideas?
 * <!– I NEED TO POST AN IMAGE FROM THE IMG and THEN TWO SEPERATE LINKS BELOW – 
   1/ WEBSITE 2/ MYSPACE URL –>
 * <div class=”artist-details”>
    <?php $artistimageCode = get_post_meta ($post -
   >ID, ‘artist-image’, true); $websiteCode = get_post_meta ($post ->ID, ‘website-
   address’, true); $myspaceCode = get_post_meta ($post ->ID, ‘myspace’, true); ?
   >
 * <img src=”<?php echo $artistimageCode; ?>” width=”200″ height=”250″ alt=”music
   box for life artist” />
    <p>Website: ” target=”_blank”>
   </p>
    <p>Myspace: ” target
   =”_blank”>
   </p>
    </div> <!– artist details close –>
 * <!– ARTIST CLOSE –>

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/custom-fields-get_post_meta-question/#post-1223674)
 * From my notes from a thread I can’t find now:
 *     ```
       <?php
       //if custom field is present, formulate and display link from meta value
       $link = get_post_meta($post->ID, 'link_url', true);
       $text = get_post_meta($post->ID, 'link_text', true);
       if ($link){
       echo 'Credit: <a href="'.$link .'">'.$text.'</a>';
       }
       ?>
       ```
   
 *  Thread Starter [gerrycircus](https://wordpress.org/support/users/gerrycircus/)
 * (@gerrycircus)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/custom-fields-get_post_meta-question/#post-1223680)
 * I tried that and it’s still not working. Here’s my latest effort:
 * >  <!– I NEED TO POST AN IMAGE FROM THE IMG and THEN
   >  TWO SEPERATE LINKS BELOW–
   > 1/ IMAGE
   >  2/ WEBSITE 3/ MYSPACE URL
   > THE IMAGE PART IS WORKING AND THE BACKEND OF WORDPRESS REGISTERS THE FACT THAT
   > ARTIST-IMAGE IS THERE
   >  –>
   > <div class=”artist-details”>
   >  <?php $artistimageCode = get_post_meta ($post-
   > >ID, ‘artist-image’, true); $websiteCode = get_post_meta ($post ->ID, ‘website-
   > address’, true); $myspaceCode = get_post_meta ($post ->ID, ‘myspace’, true);?
   > >
   >  <img src=”<?php echo $artistimageCode; ?>” width=”200″ height=”250″ alt=”music
   > box for life artist” />
   >  ” target=”_blank” /> ” target=”_blank” /> </div> <!–
   > artist details close –>
   > <!– ARTIST CLOSE –>
 * The forum is not displaying my code properly
 * I am essentially placing the php echo where the href path would be. Not sure 
   why it doesnt display here.
 *  Thread Starter [gerrycircus](https://wordpress.org/support/users/gerrycircus/)
 * (@gerrycircus)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/custom-fields-get_post_meta-question/#post-1223687)
 *     ```
       <!-- I NEED TO POST AN IMAGE FROM THE IMG and THEN
       TWO SEPERATE LINKS BELOW - 
   
       1/ IMAGE
       2/ WEBSITE
       3/ MYSPACE URL 
   
       THE IMAGE PART IS WORKING AND THE BACKEND OF WORDPRESS REGISTERS THE FACT THAT ARTIST-IMAGE IS THERE
       -->
   
       <div class="artist-details">
       	<?php
           $artistimageCode = get_post_meta ($post ->ID, 'artist-image', true);
           $websiteCode = get_post_meta ($post ->ID, 'website-address', true);
           $myspaceCode = get_post_meta ($post ->ID, 'myspace', true);
           ?>
   
           <img src="<?php echo $artistimageCode; ?>" width="200" height="250" alt="music box for life artist" />
           <?php echo $websiteCode; ?>" />
           <?php echo $myspaceCode; ?>" />
       </div>
       <!-- artist details close -->
   
       <!-- ARTIST CLOSE -->
       ```
   
 *  [Peter Boosten](https://wordpress.org/support/users/pboosten/)
 * (@pboosten)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/custom-fields-get_post_meta-question/#post-1223694)
 * What’s the value of both custom fields? Show an example.
 * Peter
 *  Thread Starter [gerrycircus](https://wordpress.org/support/users/gerrycircus/)
 * (@gerrycircus)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/custom-fields-get_post_meta-question/#post-1223695)
 * Hi Pboosten! Thanks for taking the time out of your day to help me.
 * **the custom field entries from the back-end are called:**
 * “artist-image” (this is working)
    “website-address” (this throws an error) “myspace”(
   this throws an error)
 * The problem is when I try to ADD a custom field in the backend of WP it says “
   An unidentified error has occured”.
 *  [Peter Boosten](https://wordpress.org/support/users/pboosten/)
 * (@pboosten)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/custom-fields-get_post_meta-question/#post-1223698)
 * But what do you put in as value for those custom fields?
 * Peter
 *  Thread Starter [gerrycircus](https://wordpress.org/support/users/gerrycircus/)
 * (@gerrycircus)
 * [16 years, 8 months ago](https://wordpress.org/support/topic/custom-fields-get_post_meta-question/#post-1223707)
 * hey peter
 * you got me thinking! i was focussing on the scripting. I updated my version of
   WP to the latest (just in case) and deleted all my previous entries for custom
   fields. I re-inputted them and it’s working!
 * Thanks for that!

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

The topic ‘custom fields get_post_meta question’ is closed to new replies.

## Tags

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

 * 7 replies
 * 3 participants
 * Last reply from: [gerrycircus](https://wordpress.org/support/users/gerrycircus/)
 * Last activity: [16 years, 8 months ago](https://wordpress.org/support/topic/custom-fields-get_post_meta-question/#post-1223707)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
