WordPress.org

Forums

Is_Page renders incorrectly in in IE6 (7 posts)

  1. drummergirl
    Member
    Posted 5 years ago #

    I am trying to add the following conditional statement to my theme but it does not work in IE6. Basically, I want each page to have a different class and display a different bg image.

    Works perfectly in all browsers except IE6.

    In IE6, the front page image shows up fine, but on all other pages no image displays. The html and CSS code validates. When I look at the source code, the html output is correct so why doesn't it pick up the image from the stylesheet? Any clues?

    <?php
    		if (is_front_page())  {
    		echo "<div id='wrap' class='bg-home'>";}
    
    		elseif (is_page('licensing'))  {
    		echo "<div id='wrap' class='bg-licensing'>";}
    
    		elseif (is_page('about'))  {
    		echo "<div id='wrap' class='bg-about'>";}
    
    		elseif (is_page('news'))  {
    		echo "<div id='wrap' class='bg-news'>";}
    
    		elseif (is_page('artist-writer'))  {
    		echo "<div id='wrap' class='bg-artist'>";}
    
    		elseif (is_page('store'))  {
    		echo "<div id='wrap' class='bg-store'>";}
    
    		elseif (is_page('contact'))  {
    		echo "<div id='wrap' class='bg-contact'>";}
    
    		else {echo "<div id='wrap' class='bg-home'>";}
    	?>
  2. esmi
    Forum Moderator
    Posted 5 years ago #

    It's not an issue with is_page (which is parsed well before the markup reaches any browser) but is more likely to be a CSS issue.

  3. drummergirl
    Member
    Posted 5 years ago #

    Yup - that was it. IE6 doesn't handle multiple classes - doh! I changed it each dive to a separate ID instead of a differentiating class and it worked perfectly. Thanks.

  4. syncbox
    Member
    Posted 5 years ago #

    IE6 handles multiple classes just fine.

    I'd minimize your code to write the else/if stuff solely for the class to add...

    eg:

    <div id="wrap" class="<php
    if (is_front_page())  {
     echo 'bg-home';}
    elseif (is_page('licensing'))  {
     echo 'bg-licensing';}
    elseif (is_page('about'))  {
    echo'bg-about';}
    elseif (is_page('news'))  {
    echo'bg-news';}
    elseif (is_page('artist-writer'))  {
    echo'bg-artist';}
    elseif (is_page('store'))  {
    echo'bg-store';}
    elseif (is_page('contact'))  {
    echo'bg-contact';}
    else {echo 'bg-home';} ?>;">

    since the div and the id=wrap and class=" are all shared across every instance you indicate in your elseif statements.

    I'd look to see if the id was somehow counteracting the class rules you are specifying. Make those rules more important or give them greater specificity OR define their differences in your header.php file in <style> </style> rules that define the changing property value(s) conditionally.

    BTW, I tend to stick with ids for the if (is_page()) function... the title or slug can change, but the id doesn't.

    just a suggestion. HTH.

  5. esmi
    Forum Moderator
    Posted 5 years ago #

    Now I tend to deliberately use page names in this situation - precisely because page ids can change when clients delete pages that they shouldn't. All they then need to do is re-create and publish another Page with the same name to get the display back again. If I used ids, they'd have to wait for me to edit the template to reflect the new Page id.

  6. syncbox
    Member
    Posted 5 years ago #

    Yeah, I guess that is true, though mostly they seem to simply edit the title or content... I suppose both have their advantages and disadvantages.

    It's good to know what both are, that's for sure.

    My clients are less likely to delete a page than completely change its content, but that's me. I also create a role that doesn't allow them to do that -- but rather I show them how to set a page to draft status to keep it out of a menu, etc.

  7. esmi
    Forum Moderator
    Posted 5 years ago #

    I show them how to set a page to draft status to keep it out of a menu, etc.

    Tried that but still had clients who didn't listen. :-/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.