Assumes that your page depth is how the pages are organized in the page hierarchy, not custom menu hierarchy
add_filter('body_class','depth_body_class'); /** * Add page depth body class. * * Adds depth-x body class * * @author Jen Baumann * @link http://dreamwhisperdesigns.com/?p=1112 */ function depth_body_class($classes) { global $post; if (is_page()) { if ($post->post_parent) { $ancestors = get_post_ancestors($post); $depth = count($ancestors) + 1; } else { $depth = 1; } $classes[] = 'depth-' . $depth; } return $classes; }
The post Page Depth Body Class for WordPress appeared first on Dream Whisper Designs.