phpwordpresscustom-fieldsmeta-boxes

How can I display the featured icon on frontend?


Hello I applied the code I found here.

But I can't figure out how can I call this image on frontend.

I tried this so far:

$args = array('post_type' => 'katastima');
$the_query = new WP_Query($args);

while ( $the_query->have_posts() ) : $the_query->next_post();
$id= $the_query->post->ID;
$location = get_post_meta($id, 'listingimagediv', true);
echo $location;
endwhile;

but I guess this is not the correct way to get the image link from the custom metabox. Any suggestions?

Thanks in advance.


Solution

  • You get the photo ID from get_post_meta So the next step is to get the url of the image, see here

    $size = 'full';
    $icon = null;
    $attr = array( "class" => "img-responsive" );
    echo wp_get_attachment_image( $location, $size, $icon, $attr );