For my users, they never see the admin area of Wordpress. All users are authors (with varying permissions) and as far as they are concerned, they have 'projects' (currently published posts) and 'draft projects' (draft posts).
I have built a custom template for users to see all their 'projects' - a list of their posts on the front end. This works fine.
What I also want to do is show them their list of current draft posts.
My code currently only returns ALL draft posts for all users, not specific to that user. However the list of published posts, does show posts specific to that user. Here is the code I am using for the draft list:
<?php
$my_query = new WP_Query('post_status=draft&showposts=10');
?>
<div>
<?php
if ($my_query->have_posts()) : while ($my_query->have_posts()) :
$my_query->the_post();
?>
<ul>
<li>
<?php the_title(); ?>
</li>
</ul>
<?php endwhile; else: ?>
<div>
<ul>
<li><?php _e('No upcoming Posts'); ?></li>
</ul>
</div>
<?php endif; ?>
What can I include to only show that users drafts?
Thanks
Get the user ID:
$current_user = wp_get_current_user();
Then use this as a parameter within your query search:
$my_query = new WP_Query("post_status=draft&showposts=10&author=".$current_user->ID);