How to get the current user post and it’s ID?

So digging around a little i couldn’t find a solution where the WP_Query wasn’t used, so i just stuck with the query method, Using WP_Query this snippet will display the latest post that is published by the user that is logged in.

$user_id = get_current_user_id();

$args=array(
    'post_type' => 'POSTTYPE',
    'post_status' => 'published',
    'posts_per_page' => 1,
    'author' => $user_id
);                       

$wp_query = new WP_Query($args);
while ( have_posts() ) : the_post(); 
    the_title();
endwhile; 

Hope this helps someone.

Cheers

Matt

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)