How to Change Admin Post/Page Color by Status in WordPress

Snippets by IsItWP

Are you looking for a way to change the background colors of the post/page within the admin based on the current status? While there’s probably a plugin for this, we have created a quick code snippet that you can use to ban users accounts in WordPress.


All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

function posts_status_color(){
.status-draft{background: #FCE3F2 !important;}
.status-pending{background: #87C5D6 !important;}
.status-publish{/* no background keep wp alternating colors */}
.status-future{background: #C6EBF5 !important;}

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 22 best WordPress themes for podcasting and how to choose the best domain name registrar.

Comments   Leave a Reply

  1. Thanks for the snippet!

  2. Peter Wilhelm July 25, 2020 at 4:05 pm

    Thanx alot for the snippet. Solved my problem.

  3. This code snippet is obviously no longer working with new WP 4.2.2
    I have tested it at my WP and at a fresh, blank WP installation with exactly your code mentioned above. But only each second line is colored. See screenshot here: http://screencloud.net/v/CaLW
    Any idea is appreciated, thanks.

    1. Hi Viania, after your comment I did a test on a fresh install of WordPress 4.2.2 and I don’t get the problem you have. I had first assumed that it might be the post-formats and enabled them but to no avail everything was still working.


      Here is a screenshot, now with that said this is a simple snippet only adding CSS to the admin to change the background color based on a post status class. Can you inspect the table to see if something else may be overriding the snippet ?

      1. thank you for getting back to me, have you tested it with for example 4 (!) draft posts one after the other?

        You’re right, it is overwritten by this style:

        But I don’t know, where it is coming from – all plugins are disabled:
        and I changed the theme to TwentyFifteen.
        I don’t know, what styles these are, seems that these are wp-admin styles: http://screencloud.net/v/8NvQ
        I’m using WP 4.2.2 as multisite!

        1. you don’t happen to have any mu-plugins, or something within the functions.php do you?

          1. I have the for MU necessary sunrise.php plugin installed and the
            WordPress MU Domain Mapping plugin. In theme’s function is nothing from me (switched to TwentyFifteen, but same results).

          2. strange, well if you can find the location of the css, it should help to resolve the issue.

          3. I’m not familiar with WP own admin styles like you

    2. i tryed but still not working

  4. 25 WordPress Code Snippets for Enhanced Performance - ManageWP April 9, 2014 at 11:20 am

    […] Source […]

  5. Wordpress Admin - How My Custom Posts List Rolls March 2, 2014 at 2:28 am

    […] [Source] […]

  6. Great snippet!

  7. thanks you very much ! very nice and it s free …

    1. Always free 🙂 enjoy the snippet.

      1. I said “free” because some pugin is not free and do the same ! (link removed)

        1. This is very true, my goal however is to help people working with wordpress.

  8. nice one!

  9. Is there a way to change row colour based on the category the post is in?

  10. Is there a way to change color (the same effect as above) but based on the template of the page instead of the status?

    1. hhhmmm, I’m sure something like that could be done. Can you give me a little insight into the reasons. This way I can make a post about it with code,

  11. Color Code your WordPress Posts by Post Status in Admin July 25, 2011 at 8:01 am

    […] little snippet (courtesy of WordPress Code Snippets) allows you to color code the posts in your admin area, so that you can identify posts by their […]

  12. Surkho Salamov July 3, 2011 at 1:36 pm

    Thanks! that will be helpful!

    1.  Cool glad you like it.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!