Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adds the current editing post's ID to body_class in WordPress admin
// Adds the current editing post's ID to body_class in WordPress admin
// Add this code in your theme's funtions.php
function post_id_to_body_admin($pid) {
$screen = get_current_screen();
if ( 'post' == $screen->base ) {
global $post;
$pid .= ' post-id-' . $post->ID;
return $pid;
}
}
add_filter('admin_body_class', 'post_id_to_body_admin');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment