How to get image data according to Post ID in WordPress

How to get image data according to page id in WordPress:-

Get the image data in Page according to ID .

Use the following Code:-

<?php
    query_posts();
    while (have_posts()) : the_post();
    $featuredImage = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
    <div style="background:url(<?php echo $featuredImage; ?>) no-repeat;">Background Image</div>
   <?php endwhile; wp_reset_query(); ?>


Enjoy the content.

Total Page Visits: 5378 - Today Page Visits: 3

Leave a Reply