Skip to content

Instantly share code, notes, and snippets.

@nathanrice
Last active September 7, 2015 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nathanrice/af5c6b229ddbd93335ea to your computer and use it in GitHub Desktop.
Save nathanrice/af5c6b229ddbd93335ea to your computer and use it in GitHub Desktop.
<?php
//* Do NOT include the opening php tag
add_filter( 'stylesheet_uri', 'custom_replace_default_style_sheet', 10, 2 );
/**
* Replace main theme style sheet with custom one if viewing post in a particular category.
*
* Note: Replace X with the category ID you want to target.
*/
function custom_replace_default_style_sheet( $stylesheet, $stylesheet_dir ) {
if ( is_singular( 'post' ) && in_category( X ) ) {
$stylesheet = $stylesheet_dir . '/custom.css';
}
return $stylesheet;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment