{"id":17079,"date":"2012-02-25T14:55:15","date_gmt":"2012-02-25T14:55:15","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/add-custom-post-type-slugs-to-admin-body-class\/"},"modified":"2015-05-15T04:59:49","modified_gmt":"2015-05-15T04:59:49","slug":"add-custom-post-type-slugs-to-admin-body-class","status":"publish","type":"plugin","link":"https:\/\/sa.wordpress.org\/plugins\/add-custom-post-type-slugs-to-admin-body-class\/","author":4371718,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.3","stable_tag":"1.3","tested":"4.2.39","requires":"3.1","requires_php":"","requires_plugins":"","header_name":"Add Custom Post Type Slugs to Admin Body Class","header_author":"Aaron T. Grogg","header_description":"","assets_banners_color":"","last_updated":"2015-05-15 04:59:49","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"http:\/\/aarontgrogg.com\/2012\/02\/15\/wordpress-plugin-add-custom-post-type-to-admin-body-class\/","header_author_uri":"http:\/\/aarontgrogg.com\/","rating":5,"author_block_rating":0,"active_installs":10,"downloads":2754,"num_ratings":1,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":"1"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0","1.1","1.2","1.3"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[83,2858,1241],"plugin_category":[],"plugin_contributors":[83694],"plugin_business_model":[],"class_list":["post-17079","plugin","type-plugin","status-publish","hentry","plugin_tags-admin","plugin_tags-body","plugin_tags-class","plugin_contributors-aarontgrogg","plugin_committers-aarontgrogg"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/add-custom-post-type-slugs-to-admin-body-class.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>When in Admin mode, this plug-in adds classes to the <code>&lt;body&gt;<\/code> tag to let\nyour CSS know where you are.<\/p>\n\n<p>For example, if you are viewing the list of all your Posts, you would get this additional class:\n    edit-list-post\nAnd, when you are editing a Post, something like this:\n    edit-page-post<\/p>\n\n<p>Alternatively, for custom posts, for example \"movie\", you would see either:\n    edit-list-movie\nor:\n    edit-page-movie<\/p>\n\n<p>This allows you to write custom CSS and JS to interact with these varying edit pages within WP.<\/p>\n\n<p>Please let me know if you have any questions\/suggestions\/thoughts,\nAtg<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Download the ZIP<\/li>\n<li>Unzip the ZIP<\/li>\n<li>Copy\/paste the unzipped files into your WP plug-in directory (<code>\/wp-content\/plugins\/<\/code>)<\/li>\n<li>From within WP's Plugin Admin panel, Activate the plug-in<\/li>\n<li>Write some wicked CSS and JS to amaze your friends and befuddle your enemies!<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt>What does this do, exactly?<\/dt>\n<dd><ul>\n<li>Additional CSS classes are added to the HTML <code>body<\/code> tag when certain pages load in Admin mode<\/li>\n<\/ul><\/dd>\n<dt>What classes?<\/dt>\n<dd><ul>\n<li>If you are in WP Admin, if you click Posts, you will see a list of all your Posts, and the CSS class <code>edit-list-post<\/code> \nwill be added to the HTML <code>body<\/code> tag.  If you click a specific Post, you will enter the edit page for that Post, \nand the CSS class <code>edit-page-post<\/code> will be added to the HTML <code>body<\/code> tag.  Note the difference between the two:\n  edit-list-post vs. <code>edit-page-post<\/code>, <code>list<\/code> vs. <code>page<\/code>\nSimilarly, if you click Pages, the same thing as above will happen, except the word <code>post<\/code> will be replaced with \nthe word <code>page<\/code> in each of the CSS classes.  Futher, if you have custom post types, the word <code>post<\/code> will be replaced \nwith whatever your custom post type is, so a custom post type called \"Movies\" will results in the following CSS classes\nbeing added:\n  edit-list-movie vs. <code>edit-page-movie<\/code><\/li>\n<\/ul><\/dd>\n<dt>Why would I want to do this?<\/dt>\n<dd><ul>\n<li>Really only if you used some custom CSS or JS in your WP Admin.  You could color the List or Edit headers or \nbackgrounds differently, add custom validation to some fields, etc.  Maybe when you are viewing the list of Posts,\nyou want to see red column and field headers, blue when viewing Pages, and green when viewing Movies, and for the \nMovies Edit page, you have a custom field that you want to validate as some specific format, like a date or number, \nyou could add custom JS just for that page, all based on these new classes on the HTML <code>body<\/code> tag.<\/li>\n<\/ul><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.3<\/h4>\n\n<p>2015-05-15:\n* Tested in 4.2.2, plus added a few FAQs to better explain what this plugin does and why it might be useful<\/p>\n\n<h4>1.2<\/h4>\n\n<p>2015-03-13:\n* Slight mod to make this only run in admin pages, and makes sure it is a posts list page<\/p>\n\n<h4>1.0<\/h4>\n\n<p>2012-02-24:\n* Well, this is the first version, so... here it is!<\/p>","raw_excerpt":"Add Custom Post Type Slugs to Admin &amp;lt;body&amp;gt; Class","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/17079","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=17079"}],"author":[{"embeddable":true,"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/aarontgrogg"}],"wp:attachment":[{"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=17079"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=17079"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=17079"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=17079"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=17079"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/sa.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=17079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}