Last active
August 29, 2015 14:15
-
-
Save bradpotter/c655bc2f295b7515d7bc to your computer and use it in GitHub Desktop.
Change body class via a custom field value in order to change post or page layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body <?php | |
$layout = get_post_meta($post->ID, 'layout', true); | |
if ( is_singular() && $layout == 'sidebar-content' ) { | |
body_class( 'sidebar-content' ); | |
} | |
elseif ( is_singular() && $layout == 'full-width-content' ) { | |
body_class( 'full-width-content' ); | |
unregister_sidebar( 'sidebar-primary' ); | |
} | |
else { | |
body_class( 'content-sidebar' ); | |
} | |
?> itemscope="itemscope" itemtype="http://schema.org/WebPage"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment