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");

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);

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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