I want to write a conditional statement (in pseudo below to explain)
IF current logged in user is 'Author' to a custom-post-type called 'farmers' {
// Do something
} else {
// Do something else
}
My code effort so far is
<?php
// Global variable for current user ID
$user_ID;
// Create a new WP query object
$my_query = new WP_Query( array(
'post_type' => 'farmers',
'author' => $user_ID
));
// Get all the current user posts from the query object
$posts = $my_query->posts;
IF $posts = 0 {
// Do something
} else {
// Do Something else
} ?>
User can have the role "Author" in the system, but not necessarily have any posts. So I need to check the condition that this Author actually has a post. I am just not sure how to write that IF statement at the end of the code and looking for some help.
Thanks