Skip to content

Instantly share code, notes, and snippets.

@petenelson
Created May 9, 2013 19:23
Show Gist options
  • Save petenelson/5549854 to your computer and use it in GitHub Desktop.
Save petenelson/5549854 to your computer and use it in GitHub Desktop.
WordPress: Add custom CSS file to a post/page
// add to header.php prior to wp_head()
$custom_css_file = get_post_meta( get_the_id(), $key = 'custom-css-file', $single = true );
if (false !== $custom_css_file && !empty($custom_css_file))
wp_enqueue_style( get_the_id() . '-custom-css-file', get_template_directory_uri() . '/' . $custom_css_file, array(), $version_tag_here );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment