WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Custom Fields (echo within an echo): Syntax help needed!

[Resolved] 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

    @esmi

    Forum Moderator

    <?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;?>
    ?>

    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/

    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 ‘[Resolved] Custom Fields (echo within an echo): Syntax help needed!’ is closed to new replies.
Skip to toolbar