Support » Plugins » Checking if a specific post is a draft? after wp_get_recent_posts();

  • Hello,
    What I’m doing is checking for the latest post(s)
    I use
    $recent_posts = wp_get_recent_posts();

    to get the recent posts and then

    foreach( $recent_posts as $post ){
    				$wpname = $post["post_title"];
    				$wplink = get_permalink( $post["ID"] );
    				echo '
    				[WP_CFG]<br>
    				wppname="'.$wpname.'"
    				wpplink="'.$wplink.'"
    				wppactive="1"';
    				break;
    			}

    to output the latest post
    but I need to check if the post is a draft or not
    so if it is it will continue to the next post…

    But I don’t know if and if yes how to check if a post is for draft or not.

    So can you check for this and if yes how?

Viewing 3 replies - 1 through 3 (of 3 total)
  • sry to bump I know its against the rules and stuff
    but after 1 day, almost 2 days noone even tried to help :/

    guys really this is important….

    sry again mods
    but I can’t believe that anyone looking to help someone now will ever find this thread even by looking for the ‘no reply’ threads…

    if($post['post_status'] == "publish"){ //do something }
    
    else { // it's not published (i.e. draft or other) so do nothing }

    hope that helps?

    if in doubt simply do a print_r($post) and it will show the full array with keys and values.

    that’s how i found the ‘post_status’ key

    MaFt

    using

    if($post->post_status  == "publish"){ //do something }
    
    else { // it's not published (i.e. draft or other) so do nothing }

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Checking if a specific post is a draft? after wp_get_recent_posts();’ is closed to new replies.