Created
March 10, 2021 00:48
-
-
Save 0aveRyan/c21f15cf70269d39c6f31993e39afaef to your computer and use it in GitHub Desktop.
Filter WordPress Admin Body Classes and Append Post ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'admin_body_class', 'dbr_mod_admin_body_class' ); | |
/** | |
* Append Post ID to Admin Body Classes | |
*/ | |
function dbr_mod_admin_body_class( $classes ) { | |
global $post; | |
if ( is_object( $post ) && is_a( $post, 'WP_Post' ) && property_exists( $post, 'ID' ) ) { | |
$classes = $classes . " wp-post-" . $post->ID; | |
} | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment