• Resolved thegomiboy

    (@thegomiboy)


    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)

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

    (@thegomiboy)

    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?
    https://arg.designatwork.net/west-houston-chapter/

    Thread Starter thegomiboy

    (@thegomiboy)

    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.