Return to Snippet

Revision: 46497
at May 20, 2011 19:08 by erikportin


Initial Code
<?php
if ( is_page() && $post->post_parent ) {
$id = get_the_ID();
$a = get_ancestors( $id, 'page' );
$root=count($a)-1;
$rootId = $a[$root];
}
else {
$rootId = get_the_ID();
}
?>


<body <?php body_class(); ?> id="root-id-<?php echo $rootId ?>">

Initial URL

                                

Initial Description

                                

Initial Title
Check first parent of page in Wordpress and add body id

Initial Tags
php, wordpress

Initial Language
PHP