Thursday, March 1, 2018

How to select all post data from database in wordpress | Wordpress.

$querystr = "
    SELECT $wpdb->posts.* 
    FROM $wpdb->posts, $wpdb->postmeta
    WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id 
   
  
    AND $wpdb->posts.post_status = 'publish' 
    AND $wpdb->posts.post_type = 'post'
    AND $wpdb->posts.post_date < NOW()
    ORDER BY $wpdb->posts.post_date DESC
 LIMIT 1
 ";

 $pageposts = $wpdb->get_results($querystr, OBJECT);
 //print_r($pageposts);

No comments:

Post a Comment