Skip to content

Instantly share code, notes, and snippets.

@dnavarrojr
Last active December 18, 2019 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnavarrojr/9282d795a258ff194d7938ae43dfac8c to your computer and use it in GitHub Desktop.
Save dnavarrojr/9282d795a258ff194d7938ae43dfac8c to your computer and use it in GitHub Desktop.
Attempt to add a CLASS to the BODY tag in WordPress, not working.
<?php
add_filter( 'body_class', function( $classes ) {
$restrict_page = ( get_field( 'msp_registration_required' ) ? true : false );
error_log( "before count = " . count( $classes ) );
if ( $restrict_page ) {
$classes[] = 'msp-restrict-page';
}
error_log( "after count = " . count( $classes ) );
return $classes;
} );
@dnavarrojr
Copy link
Author

Theme: BeaverBuilder Version: 1.7.4.1
WordPress: 5.3.1

@dnavarrojr
Copy link
Author

Count before 7
Count after 8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment