Title: WordPress &amp; PHP help
Last modified: August 19, 2016

---

# WordPress & PHP help

 *  Resolved [iversoncreative](https://wordpress.org/support/users/iversoncreative/)
 * (@iversoncreative)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/wordpress-amp-php-help/)
 * This is my current code:
 *     ```
       <body <?php if (is_front_page()) { ?>
       id="home"<?php } else { ?>
       id="interior" class="<?php echo $post->post_name; ?>"<?php } ?>>
       ```
   
 * Which gives me an ID of home if it’s the front page and an ID of INTERIOR if 
   it’s an interior page. Then it assigns a class of the page’s slug.
 * I would love to assign the body tag a class of the PAGE SLUG if it’s a top level
   page, the PARENT PAGE SLUG if it’s a second level page or the ANCESTOR PAGE SLUG
   if it’s a third level page.
 * Any ideas? I’m new to PHP, and barely understand it, but would there be another
   if statement? And what’s the template tag for a parent and ancestor page’s slug?
 * Any and all help is appreciated…
 * -Patrick

Viewing 1 replies (of 1 total)

 *  Thread Starter [iversoncreative](https://wordpress.org/support/users/iversoncreative/)
 * (@iversoncreative)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/wordpress-amp-php-help/#post-1112393)
 * The new body_class in version 2.8 solved this issue. Thanks WordPress!!!
 * [http://www.nathanrice.net/blog/wordpress-2-8-and-the-body_class-function/](http://www.nathanrice.net/blog/wordpress-2-8-and-the-body_class-function/)

Viewing 1 replies (of 1 total)

The topic ‘WordPress & PHP help’ is closed to new replies.

## Tags

 * [parent page](https://wordpress.org/support/topic-tag/parent-page/)
 * [slug](https://wordpress.org/support/topic-tag/slug/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [iversoncreative](https://wordpress.org/support/users/iversoncreative/)
 * Last activity: [16 years, 11 months ago](https://wordpress.org/support/topic/wordpress-amp-php-help/#post-1112393)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
