Vous cherchez un moyen de changer les couleurs d’arrière-plan d’un article ou d’une page dans l’interface d’administration en fonction de son statut actuel ? Bien qu’il existe probablement un plugin pour cela, nous avons créé un extrait de code rapide que vous pouvez utiliser pour bannir des comptes d’utilisateurs dans WordPress.
Instructions:
Tout ce que vous avez à faire est d’ajouter ce code dans le fichier functions.php de votre thème ou dans un plugin spécifique à votre site:
add_action('admin_footer','posts_status_color'); function posts_status_color(){ ?> <style> .status-draft{background: #FCE3F2 !important;} .status-pending{background: #87C5D6 !important;} .status-publish{/* no background keep wp alternating colors */} .status-future{background: #C6EBF5 !important;} .status-private{background:#F2D46F;} </style> <?php }
Note : Si c’est la première fois que vous ajoutez des extraits de code dans WordPress, veuillez vous référer à notre guide sur comment copier/coller correctement des extraits de code dans WordPress, afin de ne pas casser accidentellement votre site.
Si vous avez aimé cet extrait de code, n’hésitez pas à consulter nos autres articles sur le site comme : 22 meilleurs thèmes WordPress pour le podcasting et comment choisir le meilleur registrar de nom de domaine.
Thanks for the snippet!
Thanx alot for the snippet. Solved my problem.
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.
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.
http://wpsnipp.com/wp-content/uploads/2015/06/sample.png
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 ?
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:
http://screencloud.net/v/BNC7
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!
you don’t happen to have any mu-plugins, or something within the functions.php do you?
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).
strange, well if you can find the location of the css, it should help to resolve the issue.
I’m not familiar with WP own admin styles like you
i tryed but still not working
[…] Source […]
[…] [Source] […]
Great snippet!
thanks you very much ! very nice and it s free …
Always free 🙂 enjoy the snippet.
I said “free” because some pugin is not free and do the same ! (link removed)
This is very true, my goal however is to help people working with wordpress.
nice one!
Is there a way to change row colour based on the category the post is in?
Is there a way to change color (the same effect as above) but based on the template of the page instead of the status?
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,
[…] 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 […]
Thanks! that will be helpful!
Cool glad you like it.