Skip to content

Commit ef4c2bc

Browse files
nacinrdworth
authored andcommitted
Allow a post custom field of body_class (separated by spaces) to inject classes into the body element.
(cherry picked from commit aa2e690)
1 parent 584cea7 commit ef4c2bc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

mu-plugins/jquery-filters.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,12 @@ function jquery_unfiltered_html_for_term_descriptions() {
5959

6060
// Bypass multisite checks.
6161
add_filter( 'ms_site_check', '__return_true' );
62+
63+
// Add body classes found in postmeta.
64+
add_filter( 'body_class', function( $classes ) {
65+
if ( ! is_singular() )
66+
return $classes;
67+
if ( ! $post_classes = get_post_meta( get_queried_object_id(), 'body_class', true ) )
68+
return $classes;
69+
return array_merge( $classes, explode( ' ', $post_classes ) );
70+
});

0 commit comments

Comments
 (0)