Ever need to apply specific CSS to a post? Here’s a quick tutorial for adding custom CSS to an individual WordPress post.

This entry was posted in WordPress and tagged Css Style, Custom Css, Custom Javascript, Echo, Few Days, Meta, Php, Strlen, Style Css, WordPress. Bookmark the permalink.
Posted on January 26, 2011 by Christopher Ross.
A few days back I wrote a post which allowed site owners to add Custom JavaScript for a Specific Post, this is the second part of that tutorial which allows you to add custom CSS to a specific post:


if (is_single()) {

$css =  trim(get_post_meta($_GET['p'], 'css', true));

if (strlen($css) > 0) {
echo "<style><!-- $css --></style>";

Just add a custom field called “css” to the post and the content will be displayed in the file header. Remember, this code needs to be placed in theelement of your website’s header.php file.

Leave a Reply

Your email address will not be published. Required fields are marked *