"> ...then add appropriate CSS declarations as desired. === NEW: Custom Classes via custom fields === Custom classes can now be added via the custom field 'classybody'. Multiple classes are allowed using letters, numbers and dashes (nothing else). */ function classybody() { global $post; echo( (is_home()) ? "home" : "" ); echo( (is_page()) ? "page page-" . $post->ID . " " : "" ); echo( (is_single()) ? "post post-" . $post->ID . single_month_title(' ', false) . " " : "" ); echo( (is_category()) ? "category cat-" . intval( get_query_var('cat') ) . " " : "" ); echo( (is_year() || is_month()) ? "archive " . single_month_title(' ', false) . " " : "" ); echo( (is_search()) ? "search" : "" ); echo( (is_404()) ? "error" : "" ); if (is_page() || is_single()) { $extra = classybody_getmeta('classybody'); echo( ($extra != '') ? $extra : ""); } } function classybody_getmeta($field) { global $wpdb; $now = current_time('mysql'); $sql = "SELECT meta_value FROM $wpdb->posts AS posts, $wpdb->postmeta AS postmeta "; $sql .= "WHERE posts.ID = postmeta.post_id AND postmeta.meta_key = '$field' "; $sql .= "AND ( posts.post_status = 'publish' OR posts.post_status = 'static' ) "; $sql .= "AND posts.post_date < '$now' AND postmeta.meta_value != ''"; $results = array(); $results = $wpdb->get_results($sql); if (!empty($results)) foreach ($results as $result) { $values .= $result->meta_value . " "; }; return preg_replace("/[^a-zA-Z0-9- ]/", "", $values); } ?>