0
X
Add Snippet To Project
New Project
Add To Existing Project
<?php
/**
* Plugin Name: My Custom Plugin
* Description: Adds a custom column to display post IDs in the admin area.
*/
// Add custom column to posts listing table
function wpturbo_add_post_id_column($columns) {
$columns['post_id'] = 'Post ID';
return $columns;
}
add_filter('manage_posts_columns', 'wpturbo_add_post_id_column');
// Display post ID in the custom column
function wpturbo_display_post_id($column, $post_id) {
if ($column === 'post_id') {
echo $post_id;
}
}
add_action('manage_posts_custom_column', 'wpturbo_display_post_id', 10, 2);
This code adds a custom column named 'Post ID' to the posts listing table in the admin area. The 'wpturbo_add_post_id_column' function is used to add the column to the 'manage_posts_columns' filter hook. Then, the 'wpturbo_display_post_id' function is hooked into the 'manage_posts_custom_column' action to display the post ID in the custom column.
Save this updated code in your 'wp-plugin.php' file, and you should now see the post IDs displayed in the admin area's posts listing table.