Skip to content

Instantly share code, notes, and snippets.

@wpspeak
Created December 18, 2014 04:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpspeak/d2251398d0c9c06ef404 to your computer and use it in GitHub Desktop.
Save wpspeak/d2251398d0c9c06ef404 to your computer and use it in GitHub Desktop.
Conditionally add custom body class in WordPress
<?php
add_action( 'body_class', 'wpspeak_conditional_body_class');
function wpspeak_conditional_body_class( $classes ) {
if ( is_page( array( 'page-1', 'page-2', 'page-3' ) ) ) {
$classes[] = 'my-custom-page';
}
return $classes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment