Skip to content

Instantly share code, notes, and snippets.

@pippinsplugins
Created May 7, 2012 15:23
Show Gist options
  • Save pippinsplugins/2628380 to your computer and use it in GitHub Desktop.
Save pippinsplugins/2628380 to your computer and use it in GitHub Desktop.
Adds the value of an ECPT meta field to the post class
function ecpt_meta_field_classes($classes) {
$meta_value = get_post_meta(get_the_ID(), 'ecpt_fieldname', true);
if($meta_value) {
$classes[] = $meta_value;
}
return $classes;
}
add_filter('post_class', 'ecpt_meta_field_classes');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment