WordPress.org

Forums

[resolved] WordPress & PHP help (2 posts)

  1. iversoncreative
    Member
    Posted 6 years ago #

    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

  2. iversoncreative
    Member
    Posted 6 years ago #

    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/

Topic Closed

This topic has been closed to new replies.

About this Topic