Title: Custom Fields (echo within an echo): Syntax help needed!
Last modified: August 20, 2016

---

# Custom Fields (echo within an echo): Syntax help needed!

 *  Resolved [thegomiboy](https://wordpress.org/support/users/thegomiboy/)
 * (@thegomiboy)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/custom-fields-echo-within-an-echo-syntax-help-needed/)
 * Hi, could someone correct the code below? I’m trying to use an if/then statement
   to display content based on whether the specific custom field value exists. I’ve
   gotten it to work, but I can’t get the get_post_meta info to echo within the 
   link:
 *     ```
       <?php
       $facebook = get_post_custom_values("FB");
   
       if ($facebook == '')  {
            echo '<li id="facebook">','<a href="',get_post_meta($post->ID, FB, true),'" target="_blank">','Facebook','</a>','</li>';
            }
       else {  
   
            }
       ?>
       ```
   
 * Any help would be greatly appreciated!

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

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/custom-fields-echo-within-an-echo-syntax-help-needed/#post-2592823)
 *     ```
       <?php
       $facebook = get_post_custom_values("FB");
       if ($facebook == '') :?>
            <li id="facebook"><a href="<?php echo get_post_meta($post->ID, FB, true);?>" target="_blank">Facebook</a></li>
       <?php else : ?>
   
       <?php endif;?>
       ?>
       ```
   
 *  Thread Starter [thegomiboy](https://wordpress.org/support/users/thegomiboy/)
 * (@thegomiboy)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/custom-fields-echo-within-an-echo-syntax-help-needed/#post-2592825)
 * Thanks so much esmi, but it still doesn’t seem to work. I do notice an errant?
   > in the outputted html. Perhaps there’s a typo in your syntax?
    [http://arg.designatwork.net/west-houston-chapter/](http://arg.designatwork.net/west-houston-chapter/)
 *  Thread Starter [thegomiboy](https://wordpress.org/support/users/thegomiboy/)
 * (@thegomiboy)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/custom-fields-echo-within-an-echo-syntax-help-needed/#post-2592827)
 * Sorry, it was my syntax! lol. Cleared it up but it’s still not pulling the value
   in the URL. It does pull the value in HTML, though. Any thoughts?

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

The topic ‘Custom Fields (echo within an echo): Syntax help needed!’ is closed to
new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [thegomiboy](https://wordpress.org/support/users/thegomiboy/)
 * Last activity: [14 years, 3 months ago](https://wordpress.org/support/topic/custom-fields-echo-within-an-echo-syntax-help-needed/#post-2592827)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
