Let current user know pending posts counts using wp_query
I'm working on a query to let a logged-in user know if the user has more than 5 pending posts. Here's what I ended up with:
// Start the query
$query = new WP_Query( array(
'post_type' = 'post',
'author' = get_current_user_id(),
'post_status' = 'pending',
'posts_per_page' = -1
));
// Start the loop
if ( $query-have_posts() ) {
if ( $query-found_posts = 5 ) {
echo '5 or more pending posts';
} else {
echo 'Less than 5 pending posts';
}
wp_reset_postdata();
} else {
echo 'Nothing found!';
}
It seems working. Is there anything missing? Is there anything to correct?