Category: Snippets
This article also touches on: Adding CSS in admin footer
Draft status highlighting
A client wanted to display items with ‘Draft’ status differently (gray color) in the admin list pages. Some might argue I’m a sloppy coder for using inline CSS, but there’s something I like about targeted post types, particularly in admin pages. Anyway, here’s a good example of using the ‘admin_footer’ action and certain global variables, very useful.
This snippet (stick it in your ‘functions.php’ file) changes the link color for posts, pages, and a specially-registered post type called ‘doohickey’ here:
// make draft status items gray instead of blue link color
add_action('admin_footer','bdes_draftcss_lists');
function bdes_draftcss_lists() {
global $typenow, $pagenow;
if ($pagenow != 'edit.php') return;
switch ($typenow):
case 'post':
case 'page':
case 'doohickey':
?><style type="text/css">
tr.status-draft td.post-title a {
color: #777;
}
</style>
<?php break;
endswitch;
}