Return to Snippet

Revision: 23536
at February 9, 2010 03:31 by gd6d

Initial Code
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';
        if (file_exists($serverfilepath)) {
            echo "<link rel='stylesheet' type=text/css' href='$publicfilepath' media='screen' />"."\n";
add_action('wp_head', 'artStyle');

Initial URL

Initial Description
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.

Initial Title
Custom CSS Per Post

Initial Tags
css, post, wordpress

Initial Language