There are certain posts where I want to manually append a custom body class using custom fields.
How do I go about it appending the class to the body tag when a certain custom field is added to a post?
I have tried the following but the custom fields name tagbody
is not shown in the dropdown:
add_filter( 'body_tag', 'body_tag_name' );
add_filter( 'get_the_body_tag_name', 'body_tag_name' );
function body_tag_name( $name ) {
global $post;
$btag = get_post_meta( $post->ID, 'tagbody', true );
if ( $btag )
$name = $btag;
return $name;
}