我试图在编辑后屏幕上的评论列表表上显示每个评论日期。目前只显示作者姓名、IP地址和评论内容。
https://developer.wordpress.org/reference/classes/wp_post_comments_list_table/
有什么线索吗?谢谢
我试图在编辑后屏幕上的评论列表表上显示每个评论日期。目前只显示作者姓名、IP地址和评论内容。
https://developer.wordpress.org/reference/classes/wp_post_comments_list_table/
有什么线索吗?谢谢
因此,似乎您无法“适当”解决此问题,但是,您可以从this answer 并将其应用于您的问题:
<?php
add_filter( \'get_comment_author_IP\', function( $comment_author_IP, $comment_ID, $comment )
{
global $pagenow;
if( is_admin() && \'post.php\' === $pagenow && isset( $_GET[\'post\'] ) ) {
$comment_date = do_something_to_get_comment_date($comment_ID);
$comment_author_IP .= \' <span>Posted On:</span> \' . $comment_date;
}
return $comment_author_IP;
}, 10, 3 );
这允许您修改随注释的IP地址返回的内容。你一定要确保if
check只修改在您需要的特定情况下返回的数据,因此您可能需要考虑如何编写该条件,以避免额外数据泄漏到不应该存在的地方。comment_author
因为它不是UI中的函数字符串。此外,我添加的门是错误的,因为在编辑帖子时,评论是通过AJAX传入的,所以我也更新了检查:
add_filter( \'get_comment_author\', function( $comment_author, $comment_ID, $comment )
{
global $pagenow;
if ( ! is_admin() ) {
return $comment_author;
}
if ( ! isset( $_POST[\'action\'] ) || \'get-comments\' !== filter_var( $_POST[\'action\'], FILTER_SANITIZE_STRING ) ) {
return $comment_author;
}
$comment_author .= \' | \' . get_comment_date( \'\', $comment_ID );
return $comment_author;
}, 10, 3 );
对于自定义帖子类型,我通过php和CPT启用了对注释的支持。 \'supports\' => array( \'title\', \'editor\', \'revisions\', \'comments\', ) 但每篇文章的讨论字段中仍有未选中的“允许评论”框。我现在正在寻找一种方法来自动选中此框,因为我有相当多的这种自定义帖子类型的帖子,我不认为,这只能手动完成。但