wordpress conditional statements

Posted by codedude on Stack Overflow See other posts from Stack Overflow or by codedude
Published on 2010-03-25T15:42:12Z Indexed on 2010/03/25 15:53 UTC
Read the original article Hit count: 397

Filed under:
|

I am using this code in wordpress to display different content when different pages are loaded. I have 5 pages on the site called Home, Bio, Work, Contact and Notes. The Notes page is being used as a blog. Here is the code I am using.

                    <?php if (is_page('contact')) { ?>
                    get in touch with me
                <?php } elseif (is_single()) { ?>
                    a note from me
                <?php } elseif (is_page('notes')) { ?>
                    the notes of me
                <?php } else { ?>
                    the <?php the_title(); ?> of me
                <?php } ?>

So if it the contact page, it displays "get in touch with me" and if it is a single blog post page it displays "a note from me". However this is where I have a problem. The next statement should display "the notes of me" when it is on the Notes page. However, this does not happen. Instead it shows the default content which is in the "else" statement. any idea on why this is happening?

© Stack Overflow or respective owner

Related posts about Wordpress

Related posts about php