I was working on some project and there is a requirement that I would like to load a style-sheet on specific admin pages. e.g
WordPress is very rich CMS and application and we can do anything I believe. I know there is a way to do this and after reading codex a lot I found get_current_screen function. This function returns an object that includes the screen’s ID, base, post type, and taxonomy, among other data points. I would simply like to use
get_current_screen in my functions.php to determine if the admin page loaded is 1 of the 3 pages and if so load a css file.
We can get the current screen and set the page IDs we would like to include any scripts or styles. We then make sure that there is a
$_GET['post'] set which holds our post->ID and we also want to make sure we’re in the correct post type (though you could probably skip the whole current screen thing entirely and just use
$_GET). We then check to see if the current post ID is in our array of accepted IDs and if so: enqueue. Here is a sample code from codex that can help us.
Thanks Howdy_McGee for this solution.
I’m a Web Developer who is constantly learning the trade. I’ve built and manage 50+ WordPress websites with the help of the talented Web Designers around me. I’m currently looking for ways I can help the WordPress community grow and maintain its awesomeness!