Skip to content

Instantly share code, notes, and snippets.

@georgestephanis
Created August 14, 2012 21:05
Show Gist options
  • Select an option

  • Save georgestephanis/3353037 to your computer and use it in GitHub Desktop.

Select an option

Save georgestephanis/3353037 to your computer and use it in GitHub Desktop.
For Greg
</head>
<?php
$class = '';
if( is_page() ) {
global $post;
/* Get an array of Ancestors and Parents if they exist */
$parents = get_post_ancestors( $post->ID );
/* Get the top Level page->ID count base 1, array base 0 so -1 */
$id = ( $parents ) ? array_pop( $parents ) : $post->ID;
$class = 'descended-from-page-' . $id;
}
?>
<body <?php body_class( $class ); ?>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment