admin管理员组

文章数量:1208155

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 :

Sorry for my poor english...

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 :

Sorry for my poor english...

Share Improve this question edited Dec 1, 2020 at 9:55 eliodata asked Nov 30, 2020 at 9:32 eliodataeliodata 11 bronze badge 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 Commented Nov 30, 2020 at 9:46
Add a comment  | 

1 Answer 1

Reset to default 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.

本文标签: Display date and time into post edit comments section