INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Why is my condition being ignored?

Why is my condition being ignored?

(OP)
Good morning,

In my header.php file I have a condition that changes the background image if the user is on a certain page. Actually I want it to be for a certain template, but in the meantime just to test the code I've changed it to a specific page.

CODE

<div id="page">
<?php if (is_page('438')){
echo '<div id="header2">';
} else; ?>


This is one of the first bits of PHP I've written myself without cheating and it does load the page without errors (a major step forward for me!) but it's ignoring the call to 'header2' and using the 'header' class instead. Any clues?

RE: Why is my condition being ignored?


Are you definately on a page that has the ID of 438? Remember, posts != pages.

If that's the case, try clearing your browser cache and bouncing your web server. Or make sure you've remembered to upload the PHP file :o)

Hope this helps,
Dan

 

Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page @ Code Couch: http://www.codecouch.com/dan/

Code Couch Tech Snippets & Info: http://www.codecouch.com/
 

RE: Why is my condition being ignored?

(OP)
Yeah, it does exist! Cleared cache too. So you are saying then that my code should work? As in 'if we're on page 438 load div id header2, but if we're not do the following? I suppose that's something...

RE: Why is my condition being ignored?

try adding an else condition that dumps the values of the $wp variable. (using print_r). you will then see what the state of play is and can diagnose why the condition is failing

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close