WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Custom Fields (echo within an echo): Syntax help needed! (4 posts)

  1. thegomiboy
    Member
    Posted 2 years ago #

    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!

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    <?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;?>
    ?>
  3. thegomiboy
    Member
    Posted 2 years ago #

    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/

  4. thegomiboy
    Member
    Posted 2 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic