我们有时候需要在后台看到文章id、用户id、分类id,那么可以通过一些_row_actions钩子来实现,下面是模板兔提供的一些常见的id显示代码:
function custom_post_actions($actions, $post) { $actions['id'] = 'ID:'.$post->ID; return $actions; } add_filter('post_row_actions', 'custom_post_actions', 10, 2); add_filter('page_row_actions', 'custom_post_actions', 10, 2); add_filter('user_row_actions', 'custom_post_actions', 10, 2); function custom_category_actions($actions, $category) { $actions['id'] = 'ID:'.$category->term_id; return $actions; } add_filter('category_row_actions', 'custom_category_actions', 10, 2); add_filter("post_tag_row_actions", 'custom_category_actions', 10, 2); function custom_comment_actions($actions, $comment) { $actions['id'] = 'ID:'.$comment->comment_ID; return $actions; } add_filter('comment_row_actions', 'custom_comment_actions', 10, 2);
0 个评论