Random WordPress Function

Learn about a new WordPress function every day!


Function Signature:

wp_get_comment_status

Function Description:

Retrieves the status of a comment by comment ID.

Function Examples:

⚠️ Examples below are generated with GPT-3 once every hour. Do not take them too seriously.
Consider them as some extra input in your learning process - reason about them. Will it work? What could fail?
// Example 1: Get the status of a specific comment
$comment_id = 123;
$comment_status = wp_get_comment_status( $comment_id );
echo 'The status of comment with ID ' . $comment_id . ' is: ' . $comment_status;
// Example 2: Check if a comment is approved
$comment_id = 456;
$comment_status = wp_get_comment_status( $comment_id );
if ( 'approved' === $comment_status ) {
    echo 'The comment with ID ' . $comment_id . ' is approved.';
} else {
    echo 'The comment with ID ' . $comment_id . ' is not approved.';
}
// Example 3: Handling a non-existent comment ID
$comment_id = 789;
$comment_status = wp_get_comment_status( $comment_id );
if ( false === $comment_status ) {
    echo 'Comment with ID ' . $comment_id . ' does not exist.';
} else {
    echo 'The status of comment with ID ' . $comment_id . ' is: ' . $comment_status;
}