welsper, then Chuck.
Version: 3.0
Author: Adam Burmister
Author URI: http://www.flog.co.nz
*/
/*------------------------------------------------------------------------------
CONFIGURATION:
Copy this file into your WordPress plugins directory (/wp-content/plugins/) and
activate it in the plugins manager list.
Then within your post add a custom field with the meta-names defined below and
enter the path to your CSS or JS in the value field.
Define your custom metatags here.
------------------------------------------------------------------------------*/
$post_meta_css_name = "CSS"; //name of CSS metatag entered in your posts
$post_meta_javascript_name = "JS"; //name of JS metatag entered in your posts
/***** Configuration done: Do not alter the following *************************/
function per_post_css_js() {
global $single, $post_meta_cache, $posts, $wpdb, $id, $post_meta_css_name, $post_meta_javascript_name;
if ($single) {
// Loop through all posts and do includes
foreach ($posts as $post) {
$id = $post->ID;
// Grab the metatags
$array_css = get_post_custom_values($post_meta_css_name);
$array_js = get_post_custom_values($post_meta_javascript_name);
// Include Styles
if (is_array($array_css)) {
foreach ($array_css as $css){
print("\t\n");
}
}
// Include javascripts
if (is_array($array_js)) {
foreach ($array_js as $js){
print("\t\n");
}
}
}
}
}
/* attach to head */
add_action('wp_head', 'per_post_css_js');
?>