I make a request in the database, and found a problem when outputting. That the image data is not found anywhere, tobish in the admin panel, I set it to “record miniature” and I cannot display the values ​​by means of a query. The request looks like this:

$latest = $wpdb->get_results("SELECT * FROM wp_posts WHERE post_status='publish' ORDER BY id='DESC'"); 

    3 answers 3

    The thumbnail for recording is displayed on the site not through $wpdb , but otherwise:

     if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { the_post_thumbnail(array(300,225), array("class" => "alignleft post_thumbnail")); } 

      I make it easier.

       <img src="<?php echo get_the_post_thumbnail_url(); ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" 

        And if you are too lazy to set a thumbnail each time, you can write the following function:

         function first_img(){ global $post;preg_match('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i',$post->post_content,$img); return $img['1']; } 

        And output it like this:

         <?php $img=first_img();echo $img?>