is_page -code with multiple pages in one?
-
Topic may be confusing but I couldn’t think of better one.
I’m using conditional tags and is_page -function to get some code to some particular pages. I need to have different kind of layout on different pages so is_page -code seems to work perfectly for this.
I’ve been doing it like this:
<?php if (is_page('PageName1')) { echo "code here"; } elseif (is_page('PageName2')) { echo "same code here"; } elseif (is_page('PageName3')) { echo "different code here"; } ?>
As you noticed I have same code for some of the pages. I have so many pages that it’s kind of frustrating to copy the elseif-lines many times and I started to wonder if there is some easier way. I should propably also mention that I’m not very familiar with this kind of coding as you may have already guessed.
Is there any way to have many pages inside one is_page -code – like this:
<?php if (is_page('PageName1', 'PageName2')) { echo "code here"; } elseif (is_page('PageName3')) { echo "different code here"; } ?>
It would be much easier. Is there AND or some similar code which could be used to make it work?
Thanks for help.
-TH
- The topic ‘is_page -code with multiple pages in one?’ is closed to new replies.