Return to Snippet

Revision: 22398
at January 11, 2010 21:25 by scitrenbaumgmailcom


Initial Code
<?php
$id = $wp_query->post->ID;
$css_docs = get_post_meta($id, 'custom_css', false);
$js_docs = get_post_meta($id, 'custom_javascript', false);
if (!empty($css_docs))
{
	echo '<!--Custom css for '.get_the_title().'.-->'."\n";
	foreach ($css_docs as $css)
	{
    	    	echo '<link rel="stylesheet" href="'.$css.'" type="text/css" media="screen" />'."\n";
        }
}
if (!empty($js_docs))
{
	echo '<!--Custom javascript for '.get_the_title().'.-->'."\n";
	foreach ($js_docs as $js)
	{
		echo '<script src="'.$js.'" type="text/javascript"></script>'."\n";
	}
}
?>

Initial URL
http://www.designlessbetter.com/blogless/posts/page-specific-css-and-javascript-using-wordpress-custom-fields

Initial Description
create two custom fields: one called custom_css and one called custom_js.

Initial Title
wordpress custom fields css/javascript for pages

Initial Tags
css, wordpress

Initial Language
PHP