I want to get post status, media information like the type of attachments added to the post etc in to my program. I tried this but doesn't work well

 $posts = $wpdb->get_results("SELECT  post_status FROM wp_posts WHERE 
   ID = 1  LIMIT 1");

1 Answer 1


Use the get_post (see: get_post reference) to get a post like $post = get_post(1); and then say: $post->post_status


Or even better use the get_post_status (see: get_post_status) like $post_status = get_post_status(1);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.