你好@Carson:
一个简单的函数可以满足您的要求yoursite_user_has_posts()
利用内置的WP_Query
类别:
function yoursite_user_has_posts($user_id) {
$result = new WP_Query(array(
\'author\'=>$user_id,
\'post_type\'=>\'any\',
\'post_status\'=>\'publish\',
\'posts_per_page\'=>1,
));
return (count($result->posts)!=0);
}
然后,您可以从主题中调用它,如下所示:
<?php
$user = wp_get_current_user();
if ($user->ID)
if (yoursite_user_has_posts($user->ID))
echo \'Thank you for writing!\';
else
echo \'Get Writing!\';
?>