$Featured_image = $wpdb->get_results("
SELECT p.*
FROM net_5_postmeta AS pm
INNER JOIN net_5_posts AS p ON pm.meta_value=p.ID
WHERE pm.post_id = $da_id
AND pm.meta_key = '_thumbnail_id'
ORDER BY p.post_date DESC
LIMIT 15
",'ARRAY_A'
or
SELECT * from {$wpdb->prefix}_posts
WHERE ID in (
SELECT meta_value FROM {$wpdb->prefix}_postmeta
WHERE meta_key = '_thumbnail_id'
AND post_id = ':ID'
);
if ( have_posts() ) : while ( have_posts() ) : the_post();
if ( has_post_thumbnail() ) {
$feat_image_url = wp_get_attachment_url( get_post_thumbnail_id() );
// use the $feat_image_url variable as you like
}
endwhile;
endif;
Hope this helps
Take care and happy coding
Please Try This
<?php $query = new WP_Query($args); ?>
<?php if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?>
<?php if (has_post_thumbnail()): ?>
<a class="feature_image" href="<?php echo wp_get_attachment_url( get_post_thumbnail_id(get_the_ID())); ?>">
<?php the_post_thumbnail('thumbnail'); ?>
</a>
<?php endif; ?>
The featured image is stored in the
you can get it by
or
Replace ID by your post id
To Get the Post Thumbnail URL in WordPress
for reference :URL
You can try this code
Hope this helps
Take care and happy coding
Please Try This