How To Access Meta Value Under Image Link In Wordpres

- 1 answer



while($res = mysqli_fetch_array($query)) 
                    // $img_src=wp_get_attachment_image_src(get_post_thumbnail_id($res['image']));
                    // $img_src_url=$img_src[0];
                    $post = get_post($res['post_id'] );
                    <div class="maindiv">
                  <div class="notification">
                      <img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id($id) );?>"></td>
                  <img src="<?php echo $post->_event_banner;?>"></td> 
                  <div class="notification1">
                  <h2><a href="<?php echo $res['permalink'] ?>"><?php echo $res['post_title']?></a></h2>
                  <h6><?php echo $res['date']?></h6>

how to display image give me some reference I need help on how to access the image in meta key use and filter I have not idea in meta key use give me idea... it's very important



So not sure how you're saving your meta_key in the first place? It looks like what you have is a serialized array with just a single, numerically indexed entry. So what you probably want to do is change wherever that's saved to just store the URL?

That said, you could access that meta value like this:

$banner_src = maybe_unserialize( get_post_meta( $post->ID, '_event_banner', true ) );
$banner_src = is_array( $banner_src ) ? $banner_src[0] : $banner_src;

And then display the banner like:

<img src="<?php echo $banner_src; ?>" />