ionfish (owner)

Revisions

gist: 79060 Download_button fork
public
Description:
Per-category stylesheets plugin for WordPress
Public Clone URL: git://gist.github.com/79060.git
Embed All Files: show embed
category_styles.php #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/*
Plugin Name: Category Stylesheets
Plugin URI: http://extralogical.net/projects/
Description: Apply category-specific stylesheets to posts and archives.
Author: Ben Eastaugh
Version: 1.0
Author URI: http://extralogical.net/
*/
 
function category_stylesheet_link() {
if (is_single()) {
$cats = array();
$cat_objs = get_the_category(get_the_ID());
foreach ($cat_objs as $cat)
array_push($cats, $cat->cat_ID);
} elseif (is_category()) {
$cats = array(get_query_var('cat'));
}
 
if (!isset($cats) || empty($cats)) return;
 
foreach ($cats as $cat_ID)
printf('<link rel="stylesheet" type="text/css" href="%s" />' . "\n",
get_bloginfo('stylesheet_directory') .
'/category-' . $cat_ID . '.css');
}
 
add_action('wp_head', 'category_stylesheet_link');
 
?>