Forums

Page and child page conditional css (1 post)

  1. corynathan
    Member
    Posted 9 months ago #

    Hi I'm using wp2.7 and am having problems with the following piece of code:

    <div class="grid_12" <?php
      if (is_page('Home') || $post->post_parent == '2' ) { echo " id=\"home\"";}
      elseif (is_page('About') || $post->post_parent == '4' ) { echo " id=\"about\"";}
      elseif (is_page('Services') || $post->post_parent == '7' ) { echo " id=\"services\"";}
      elseif (is_page('Plans') || $post->post_parent == '14' ) { echo " id=\"plans\"";}
      elseif (is_page('Downloads') || $post->post_parent == '22' ) { echo " id=\"downloads\"";}
      elseif (is_page('Contact') || $post->post_parent == '31' ) { echo " id=\"contact\"";}
      else {echo " id=\"white\"";} ?>><h1><?php the_title(); ?></h1>
    </div>

    What I'm trying to do is have wordpress figure out what the page is, and nominate an id style for each page and it's children in the header. The code above seems to work fine on every page except for the about page's children. I've checked the page hierarchy and all this seems fine. I'm thinking my hack might be inferior..

    Any help would be appreciated, even alternatives.

    Cheers

Reply

You must log in to post.

About this Topic