[resolved] WordPress & PHP help (2 posts)

  1. iversoncreative
    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...


  2. iversoncreative
    Posted 6 years ago #

    The new body_class in version 2.8 solved this issue. Thanks WordPress!!!


Topic Closed

This topic has been closed to new replies.

About this Topic