How to echo data after a WP_Query

I would like to display data from a post that has custom fields in a metabox. One of the fields is the URL for an image. How do I create an echo to display the image?

The other field I want to call is a link. I have one field for the URL and one field for the link text. How do I echo this to diplay the link.

Read More

Thanks,

14ner

Related posts

Leave a Reply

2 comments

  1. I think what we want might be something more like:

    <?php
      $image_url = get_post_meta($post->ID, 'image-url-field', true);
      $link_url = get_post_meta($post->ID, 'link-url-field', true);
      $link_text = get_post_meta($post->ID, 'link-text-field', true);
    
      // display inline image
      echo '<img src="' . esc_url($image_url) . '" />';
    
      // display clickable link
      echo '<a href="' . esc_url($link_url) . '">' . esc_html($link_text) . '</a>';
    ?>