Support » Developing with WordPress » Need some help with conditional logic

  • Resolved harshclimate

    (@harshclimate)


    I’m trying to write conditional statements in the header and I’m all mixed up.

    Right now I have:

    if(is_page('photographs')) : echo 'this is the photographs page'; endif;
    if(is_page('journal')) : echo 'this is the journal page'; endif;
    if(is_page('information')) : echo 'this is the information page'; endif;

    That all works great, and I’m certain it’s inefficient. However, when a user isn’t on any of those pages, I need it to echo “home”. HOME actually is appending on the end of all the aforementioned echo’s. So it reads “This is the photographs page home”.

    Grace me with your knowledge!

Viewing 1 replies (of 1 total)
  • Never mind. I think I just figured it out and what a doofus I am. I don’t know why it wasn’t working originally, but I ended up with just:

    if(is_page('photographs')) {
           echo 'This is the photographs page';
        } elseif (is_page('field-journal')) {
           echo 'This is the journal page';
        } elseif (is_page('information')) {
           echo 'This is the information page';
        }
    else echo 'None of the pages are showing';
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.