• Hello again! ??

    This time I made a custom field in which I type a link. When I tested it, the link appeared as plain text so after searching for a solution I used this

    <a href="<?php echo get_post_meta($post->ID, "link", true); ?>">Website</a>

    It takes me to the link in the custom field but “Website” appears even on the posts without a custom field added.

    Is there a way to display it just on posts with the meta added? And display the full address instead of a hyper-link?

Viewing 1 replies (of 1 total)
  • Try:

    <?php if( get_post_meta($post->ID, "link", true) ) :?>
    <a href="<?php echo get_post_meta($post->ID, "link", true); ?>">Website</a>
    <?php endif;?>

Viewing 1 replies (of 1 total)
  • The topic ‘Custom field with link’ is closed to new replies.