Title: Custom admin css for locked post
Last modified: January 13, 2021

---

# Custom admin css for locked post

 *  Resolved [Eliodata](https://wordpress.org/support/users/fgelio/)
 * (@fgelio)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/custom-admin-css-for-locked-post/)
 * Hi,
    Thank you for this plugin, works like a charm. I’m using another plugin 
   to style the wordpress admin with CSS. Is it possible to use a css class or something
   else to add a background color to the locked posts in admin pages (posts lists
   and post edit pages)? Best regards

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [andyexeter](https://wordpress.org/support/users/andyexeter/)
 * (@andyexeter)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/custom-admin-css-for-locked-post/#post-13902367)
 * Hey [@fgelio](https://wordpress.org/support/users/fgelio/),
 * For post lists, you could use the `post_class` filter to conditionally add classes
   to the table rows:
 *     ```
       add_filter('post_class', function ($classes, $class, $postId) {
           global $postlockdown;
   
           if ($postlockdown->is_post_locked($postId)) {
               $classes[] = 'postlockdown-post-locked';
           }
           if ($postlockdown->is_post_protected($postId)) {
               $classes[] = 'postlockdown-post-protected';
           }
   
           return $classes;
       }, 10, 3);
       ```
   
 * For the post edit page, you could use the `admin_body_class` filter to conditionally
   add classes to the body:
 *     ```
       add_filter('admin_body_class', function ($classes) {
           if (get_current_screen()->base === 'post') {
               $post = get_post();
   
               global $postlockdown;
   
               if ($postlockdown->is_post_locked($post->ID)) {
                   $classes .= ' postlockdown-post-locked';
               }
               if ($postlockdown->is_post_protected($post->ID)) {
                   $classes .= ' postlockdown-post-protected';
               }
           }
   
           return $classes;
       });
       ```
   
 * Hope this helps!
 *  Thread Starter [Eliodata](https://wordpress.org/support/users/fgelio/)
 * (@fgelio)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/custom-admin-css-for-locked-post/#post-13911028)
 * Hi,
    Many thanks for the quick answer! Unfortunately it is to complicated for
   my poor level 🙂 I will find another solution. Best regards
 *  Plugin Author [andyexeter](https://wordpress.org/support/users/andyexeter/)
 * (@andyexeter)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/custom-admin-css-for-locked-post/#post-13930162)
 * Hi [@fgelio](https://wordpress.org/support/users/fgelio/),
 * If you know how to edit a theme’s code, you just need to place the two code snippets
   I provided into that theme’s functions.php file
 * I have also just found [https://en-gb.wordpress.org/plugins/my-custom-functions/](https://en-gb.wordpress.org/plugins/my-custom-functions/)–
   if you are able to install plugins you could install this one and add the code
   there instead 🙂
 *  Thread Starter [Eliodata](https://wordpress.org/support/users/fgelio/)
 * (@fgelio)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/custom-admin-css-for-locked-post/#post-13931515)
 * Hi [@andyexeter](https://wordpress.org/support/users/andyexeter/),
 * The first time I tried your code into my functions.php WordPress crashed. So 
   I didn’t wanted to waste your time more.
    It finally works like a charm, don’t
   know what I did wrong for the first attempt!
 * Thank you again!
 * Regards
 *  Plugin Author [andyexeter](https://wordpress.org/support/users/andyexeter/)
 * (@andyexeter)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/custom-admin-css-for-locked-post/#post-13931622)
 * Glad you got it working! 🙂

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Custom admin css for locked post’ is closed to new replies.

 * ![](https://ps.w.org/post-lockdown/assets/icon-256x256.png?rev=3273464)
 * [Post Lockdown](https://wordpress.org/plugins/post-lockdown/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-lockdown/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-lockdown/)
 * [Active Topics](https://wordpress.org/support/plugin/post-lockdown/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-lockdown/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-lockdown/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [andyexeter](https://wordpress.org/support/users/andyexeter/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/custom-admin-css-for-locked-post/#post-13931622)
 * Status: resolved