admin管理员组文章数量:1308138
In the backend of WordPress, on the Comments page. Is possible to include a column for comment_id? Here is a visual of the locaton...
...perhaps to the left of the Comment column? If so, what would be an efficient way of doing that?
or if easier, under the 127.0.0.1 for each comment? Either way, I just need a visual because that number will be significant in what my non-technical client needs in another task.
In the backend of WordPress, on the Comments page. Is possible to include a column for comment_id? Here is a visual of the locaton...
...perhaps to the left of the Comment column? If so, what would be an efficient way of doing that?
or if easier, under the 127.0.0.1 for each comment? Either way, I just need a visual because that number will be significant in what my non-technical client needs in another task.
Share Improve this question edited Jan 14, 2021 at 17:44 klewis asked Jan 14, 2021 at 17:38 klewisklewis 8991 gold badge14 silver badges29 bronze badges1 Answer
Reset to default 2Is possible to include a column for comment_id?
Yes, and there are two hooks that you'd want to use:
manage_edit-comments_columns
— use this hook to add custom columns to the comments list table, e.g. the custom comment ID column.manage_comments_custom_column
— use this hook to display (echo
) the content for a custom column added via the above hook.
Working example you can try:
// Add the comment ID column.
add_filter( 'manage_edit-comments_columns', function ( $columns ) {
$columns['comment_id'] = 'ID';
return $columns;
} );
// Display the content of the above column.
add_action( 'manage_comments_custom_column', function ( $column_name, $comment_ID ) {
if ( 'comment_id' === $column_name ) {
echo $comment_ID;
}
}, 10, 2 );
Additionally, if I were you, I'd probably want to make the comment ID column be sortable (so that the comments list can be sorted by clicking on the "ID" column in the table header/footer), and for that, you can use the manage_edit-comments_sortable_columns
hook to add the column to the sortable columns list:
add_filter( 'manage_edit-comments_sortable_columns', function ( $columns ) {
$columns['comment_id'] = 'comment_id';
return $columns;
} );
Note that the comment_id
doesn't need extra coding to make the comments sorting works, so you could simply add the column to the sortable columns list — for other custom columns, you may need to write the code for sorting the comments based on the specific custom column.
本文标签: Add commentid on Comments page within wpadmin
版权声明:本文标题:Add comment_id on Comments page within wp-admin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741834314a2400122.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论