Created
April 4, 2013 10:03
-
-
Save leoken/5309227 to your computer and use it in GitHub Desktop.
adds a class to the top level parent of a page or post
This file contains hidden or 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
<?php | |
function top_level_parent_class($classes) { | |
global $post; | |
if (is_page() && !$post->post_parent && !is_front_page()) { | |
$classes[] = 'page-top-parent'; | |
} | |
return $classes; | |
} | |
add_filter('body_class', 'top_level_parent_class'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment