Conditional Tags and Parent/Child pages
-
Is it possible to use conditional tags to cover all the pages that have a particular parent? For example, if I have a parent page with the slug “about” and I create three child pages of “about” named “vita” “contact” and “portfolio”, how would I use conditional tags to cover all of these pages. Using if is_page(‘about’) doesn’t do the trick.
Basically, I want to change the content of my sidebar based on what parent the child page is under. Here’s my script for the sidebar:
<div id=”sidebar”>
<!– PHP includes for the sidebar…uses different include files depending on what part of the site is being viewed. –>
<?php if (is_home()) {
include (“inc/home_side.php”);
} elseif (is_archive()) {
include (“inc/archive_side.php”);
} elseif (is_page(‘work’)) {
include (“inc/work_side.php”);
} else if (is_page(‘archives’)) {
include (“inc/archives_side.php”);
} else if (is_page(‘about’)) {
include (“inc/about_side.php”);
} elseif (is_page(‘links’)) {
include (“inc/linksside.php”);
} ?>
</div>So, I want all of the child pages of the “about” page to use the include file “about_side.php” for the sidebar…make sense? Right now it only uses the include file for the “about” page.
https://clioweb.org/index3.php/about/vita/
versus
https://clioweb.org/index3.php/about/I did a search, and all I could find relevant is here. I’m familiar with using conditional tags. I know I could just write an if is_page() for every page I make, but I’d rather cover it by just specifying the parent page.
Any suggestions?
- The topic ‘Conditional Tags and Parent/Child pages’ is closed to new replies.