/ Published in: PHP

To use it, simply create a new folder called “art-direction†in your theme. Then to style any particular Post or Page, just drop a file in that folder named style-XXXX.css where XXXX is the ID of the Post or Page. When that Post or Page loads, WordPress will look for a file of that name. If it exists, it will load in in the head section.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function artStyle() { global $post; if (is_single()) { $currentID = $post->ID; $serverfilepath = TEMPLATEPATH.'/art-direction/style-'.$currentID.'.css'; $publicfilepath = get_bloginfo('template_url'); $publicfilepath .= '/art-direction/style-'.$currentID.'.css'; echo "<link rel='stylesheet' type=text/css' href='$publicfilepath' media='screen' />"."\n"; } } } add_action('wp_head', 'artStyle');
URL: http://digwp.com/2010/02/custom-css-per-post
Comments
