WP Comment Object

WP Comment Object

WP_Comment Object (
    [comment_ID] => 5
    [comment_post_ID] => 1665
    [comment_author] => webbizdirect@gmail.com
    [comment_author_email] => webbizdirect@gmail.com
    [comment_author_url] => 
    [comment_author_IP] => 192.168.42.7
    [comment_date] => 2020-01-17 13:49:26
    [comment_date_gmt] => 2020-01-17 13:49:26
    [comment_content] => Zodra er een enquête beschikbaar is die bij jou past, ontvang je een e-mail. Je kunt dan zelf bepalen of je die enquête wel of niet gaat invullen. Voor elke ingevulde enquête krijg je punten. Deze punten verschillen per enquête en hangen onder andere af van hoeveel tijd het onderzoek in beslag neemt. Nadat je de enquête hebt ingevuld, wordt de beloning vaak al binnen een paar minuten bijgeschreven op je account.
    [comment_karma] => 0
    [comment_approved] => 1
    [comment_agent] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36
    [comment_type] => review
    [comment_parent] => 0
    [user_id] => 3
    [children:protected] => 
    [populated_children:protected] => 
    [post_fields:protected] => Array (
            [0] => post_author
            [1] => post_date
            [2] => post_date_gmt
            [3] => post_content
            [4] => post_title
            [5] => post_excerpt
            [6] => post_status
            [7] => comment_status
            [8] => ping_status
            [9] => post_name
            [10] => to_ping
            [11] => pinged
            [12] => post_modified
            [13] => post_modified_gmt
            [14] => post_content_filtered
            [15] => post_parent
            [16] => guid
            [17] => menu_order
            [18] => post_type
            [19] => post_mime_type
            [20] => comment_count
        )
)

To get a ID of the comment, for example, you should use such record:

$comment_ID = $comment->comment_ID;

Useful Comment functions:

// wrapper for $comment->comment_ID
get_comment_ID();

// retrieves the author of the current comment. If the comment has an empty comment_author field, then 'Anonymous' person is assumed.
get_comment_author( $comment_ID = 0 );

// filters the comment author's returned email address. Wrapper for $comment->comment_author_email.
get_comment_author_email( $comment_ID = 0 );

// returns the HTML email link to the author of the current comment
get_comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null );

// retrieves the HTML link to the URL of the author of the current comment
get_comment_author_link( $comment_ID = 0 );

// filters the IP address of the author of the current comment. Wrapper for $comment->comment_ID
get_comment_author_IP( $comment_ID = 0 );

// retrieves the URL of the author of the current comment
get_comment_author_url( $comment_ID = 0 );

// retrieves the HTML link of the URL of the author of the current comment
get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 );

// retrieves the comment date of the current comment. $d is optional. The format of the date
get_comment_date( $d = '', $comment_ID = 0 );

// retrieves the excerpt of the current comment
get_comment_excerpt( $comment_ID = 0 );

// retrieves the link to the current post comments
get_comments_link( $post_id = 0 );

// retrieves the amount of comments a post has
get_comments_number( $post_id = 0 );

// displays the language string for the number of comments the current post has
get_comments_number_text( $zero = false, $one = false, $more = false );

// retrieves the text of the current comment
get_comment_text( $comment_ID = 0 );

// retrieves the comment time of the current comment. $d is optional. The format of the time
get_comment_time( $d = '' );

// retrieves the comment type of the current comment. Wrapper for $comment->comment_type
get_comment_type( $comment_ID = 0 );

// determines whether the current post is open for comments
comments_open( $post_id = null );

// load the comment template specified in $file. Default template can be rewriten in the current theme
comments_template( $file = '/comments.php' );


WordPress has other important comment functions, but they have many basic settings for the configuration which are passed in the array. Here is some of them:

// used in the comments.php template to list comments for a particular post
wp_list_comments( $args = array(), $comments = null );

// outputs a complete commenting form for use within a template
comment_form( $args = array(), $post_id = null );

See WordPress documentation.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.