X

highlight post_states within admin posts and pages

Adding this snippet to the functions.php of your wordpress theme will highlight the posts_states within the admin post and page sections.


( example screenshot )

Code Snippet:


function custom_post_states( $post_states ) {
foreach ( $post_states as &$state ){
$state = '<span class="'.strtolower( $state ).' states">' . str_replace( ' ', '-', $state ) . '</span>';
}
return $post_states;
}
add_filter( 'display_post_states', 'custom_post_states' );

function custom_post_states_css(){
echo '<style>
.post-state .states{
font-size:10px;
padding:3px 8px 3px 8px;
-moz-border-radius:2px;
-webkit-border-radius:2px;
border-radius:2px;
}
.post-state .password{background:#000;color:#fff;}
.post-state .pending{background:#83CF21 !important;color:#fff;}
.post-state .private{background:#E0A21B;color:#fff;}
.post-state .draft{background:#006699;color:#fff;}
</style>';
}
add_action('admin_head','custom_post_states_css');

Comments  Leave a Reply

  1. Thanks for this. It should make a good companion to the (now updated) custom statuses snippet.

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!