条件文を書きたい(以下疑似で説明)
IF current logged in user is 'Author' to a custom-post-type called 'farmers' {
// Do something
} else {
// Do something else
}
これまでの私のコード作業は
<?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
} ?>
ユーザーはシステムで「作成者」の役割を持つことができますが、必ずしも投稿を持っているとは限りません。したがって、この Author が実際に投稿しているという条件を確認する必要があります。コードの最後にその IF ステートメントを記述する方法がわからず、助けを求めています。
ありがとう