wp_get_comment_status

函数
wp_get_comment_status ( $comment_id )
参数
  • (int|WP_Comment) $comment_id Comment ID or WP_Comment object
    Required:
返回值
  • (string|false) Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
定义位置
相关方法
wp_set_comment_statusget_comment_statuseswp_transition_comment_statusget_default_comment_statusget_comment_text
引入
1.0.0
弃用
-

wp_get_comment_status: 这个函数检索一个评论的状态。它接受评论ID作为参数,并返回一个包含评论状态的字符串。

通过评论ID检索评论的状态。

function wp_get_comment_status( $comment_id ) {
	$comment = get_comment( $comment_id );
	if ( ! $comment ) {
		return false;
	}

	$approved = $comment->comment_approved;

	if ( null == $approved ) {
		return false;
	} elseif ( '1' == $approved ) {
		return 'approved';
	} elseif ( '0' == $approved ) {
		return 'unapproved';
	} elseif ( 'spam' === $approved ) {
		return 'spam';
	} elseif ( 'trash' === $approved ) {
		return 'trash';
	} else {
		return false;
	}
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 17:32:57

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: