how to get post image from attached using id in wordpress

how to get post image in wordpress 
how to  get attached id through post id in worpress


$args = array(
    'numberposts' => 1,
    'order'=> 'DESC',
    'post_mime_type' => 'image',
    'post_parent' =>$post->id,
    'post_type' => 'attachment'
    );

$get_children_array = get_children($args,ARRAY_A);  //returns Array ( [$image_ID]...
$rekeyed_array = array_values($get_children_array);
$child_image = $rekeyed_array[0];
echo '<img src="'.wp_get_attachment_thumb_url($child_image['ID']).'" class="current">';

using post id get image form post data wordpress

Comments

Popular posts from this blog

php format date string short month

Regular expression handler quicker learn in php

Android Interview Questions and Answers