Title: Custom Fields Question
Last modified: August 19, 2016

---

# Custom Fields Question

 *  Resolved [twro](https://wordpress.org/support/users/twro/)
 * (@twro)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-question-2/)
 * I’m wondering if this is at all possible using custom fields. I’d like to have
   a link (always different) to a page on each of my posts, but I’d like to use 
   the a href way of changing the name of the link to something as simple as like“
   Credit: Mr. Blogs”.
 * Is it possible?

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-question-2/#post-1092865)
 * You mean something like this?
 *     ```
       <?php
       $link = get_post_meta($post->ID, 'your_custom_field', true);
       if ($link){
       echo 'Credit: <a href="$link">Mr. Blogs</a>';
   
       }
       ?>
       ```
   
 *  Thread Starter [twro](https://wordpress.org/support/users/twro/)
 * (@twro)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-question-2/#post-1092871)
 * Yes, but could you show me how to change the ‘Mr. Blogs’ part as well each time
   using custom fields?
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-question-2/#post-1092879)
 * If that’s the case then you will need a custom field for the link/URL and a custom
   field for the link text.
 *     ```
       <?php
       $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 [twro](https://wordpress.org/support/users/twro/)
 * (@twro)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-question-2/#post-1092912)
 * It comes up perfectly, but for some reason the link url is all messed up. It 
   comes up with the blog post url and /$link after it.
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-question-2/#post-1092915)
 * What value do you have for your link_url custom field?
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-question-2/#post-1092917)
 * Oops,
 *     ```
       <?php
       $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 [twro](https://wordpress.org/support/users/twro/)
 * (@twro)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-question-2/#post-1092940)
 * No dude, it now just has the url at the end of the post :(. I’m using link_url
   as the value.
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-question-2/#post-1092945)
 * your link_url custom field value needs to be [http://www.domain.com](http://www.domain.com)
   
   your link_text custom field value needs to be Mr Blogs (or whatever)
 *  [greydog](https://wordpress.org/support/users/greydog/)
 * (@greydog)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/custom-fields-question-2/#post-1093057)
 * Following on from the above. Is there a way of allowing multiple links? I’m learning
   php so excuse the following attempt.
 *     ```
       <?php
       $links = get_post_meta($post->ID, 'linked_material_url', false);
       $text = get_post_meta($post->ID, 'linked_material_text', false);
       ?>
       	<ul>
       		<?php foreach($links as $link) {
       			echo '<a href="$link">'.$text.'</a><br />';
       			} ?>
       	</ul>
       ```
   

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

The topic ‘Custom Fields Question’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 9 replies
 * 3 participants
 * Last reply from: [greydog](https://wordpress.org/support/users/greydog/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/custom-fields-question-2/#post-1093057)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
