0

My users need to see the date and time for each comment from the post edit page. Can anyone help me to display these metadata please?

Edit: When editing a post (cpt in my case) you can see the comments related to it and create new comments or answers. But the comments metabox only display username, email, IP, and comments content. I would like the date and time to be displayed for each comments, as it is already enabled in the front end or in the admin comments section.

Better with a picture maybe :

enter image description here

Sorry for my poor english...

1
  • You can display meta data by packing the php in short code and then add the short code everywhere. * Please add more info to question for clarity.
    – w3Abhishek
    Nov 30 '20 at 9:46
0

Here is the answer given by Ferman on wpfr.net

function date_commentaire( ){

$comments = get_comments( array( 'post_id' => get_the_ID() ));

if ( doing_action( 'wp_ajax_get-comments' ) )                   
    foreach ( $comments as $comment ) : 
    $a = $comment->comment_ID;
    $b = get_comment_ID();
    $date_comment = get_comment_date();
    $time_comment = get_comment_time();

if ( $a==$b )       
    echo '<p class="commentaire-date">'.'Commentaire N°:   '.$comment->comment_ID.'   du:    '.$date_comment.' à '.$time_comment.'</p>';
    endforeach; 
    
return $comment_author_url; 
}
add_filter( 'get_comment_author_url','date_commentaire');

Works great. I just pasted it into functions.php child theme instead of using the advised plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.