2013-02-20, 06:14:08
Insert this at the beginning of your template, or in your theme's functions.php file (create it if it doesn't exist):
Then use it in your template:
In your example, it could be like this:
PHP Code:
<?php
function get_top_parent() {
$slug = return_page_slug();
while (returnPageField($slug,'parent') != '') {
$slug = returnPageField($slug,'parent');
}
echo $slug;
}
?>
Then use it in your template:
PHP Code:
<?php get_top_parent(); ?>
In your example, it could be like this:
PHP Code:
<?php // so that the syntax is highlighted correctly ?>
<body id="d-<?php get_page_slug(); ?>" class="p-<?php get_top_parent(); ?>">