could easily and quickly change the color of background if I did not like it.
To be clear, my plugin wasn’t designed to be something that you’d turn on and off for specific blog posts. It can be done, but the plugin was designed to work for all posts, without you having to touch anything.
That said, the plugin includes 2 colors, and will give you better results if you make use of the 2 colors on your site.
You can look at posts on my personal site to get an idea of how the plugin can be used.
- This post‘s featured image is grey. The plugin uses that average color for the background. Since it’s a light color, the matching contrast color is back. The plugin changed the text color to back, so text remains readable.
- This post‘s featured image is a mix of brown and purple. It’s a quite dark color. The matching contrast color is consequently white. The plugin changed the text color to white, so it stays readable.
I didn’t have to do anything with those colors; they were automatically picked by the plugin, and applied to my site with CSS, for each one of my posts.
You can do the exact same thing on your site, using CSS that matches your site’s structure, and inserting that CSS with the colorposts_css_output
filter, via a functionality plugin.
Here is an example of the code you could use to change the background color of the main post area only, and change the text color to contrast with the background color. This will apply to all your posts.
/**
* Change the background color of the main post area only.
* Change the text color to contrast with the background color.
*/
function jeherve_adjust_post_colors( $colors_css, $color, $contrast ) {
$post_id = get_the_ID();
$tonesque = get_post_meta( $post_id, '_post_colors', true );
extract( $tonesque );
$colors_css = "#wrap #content #main .post {
background-color: #{$color} !important;
color: rgb({$contrast});
}";
return $colors_css;
}
add_filter( 'colorposts_css_output', 'jeherve_adjust_title_color', 10, 3 );