看什么count_user_posts()
在内部执行并更改post type参数:
global $wpdb;
// \'page\' is the important part here
$where = get_posts_by_author_sql(\'page\', true, $userid);
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );
然后将代码段更改为:
global $wpdb;
$user = wp_get_current_user();
$where = get_posts_by_author_sql( \'page\', true, $user->ID );
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );
if ( $count >= 1 ) {
// echo your text snippet
} else {
// echo your form
}