Hello, I was wondering if it is possible to write an if statement that would check to see if a page is a "sub sub page", or to say it another way, a page that has a page parent, and that page has a page parent?
Hello, I was wondering if it is possible to write an if statement that would check to see if a page is a "sub sub page", or to say it another way, a page that has a page parent, and that page has a page parent?
This thread shows a couple possibilities:
http://wordpress.org/support/topic/179463?replies=34
Thanks for some help there Michael. I didn't come across exactly what I needed, as I couldn't figure out how to test if a page was a root page, sub page, or sub sub page.
But I figured I'd post my solution here in case its useful to anyone else. What I did is check to see if the page parent was one of my "root pages" where I could use specific ID's. If it was, it would post it's own subpages. Otherwise, it assumes that the page is a sub sub page, and posts its "brother pages". (as I deemed them)
<?php
$parentid = $post->post_parent;
if ($parentid==5 || $parentid==7 || $parentid==9 || $parentid==15 || $parentid==11) {
$children = wp_list_pages('depth=1&title_li=&child_of='.$post->ID.'&echo=0');
if ($children) { ?>
<div id="subsubnav">
<ul>
<?php echo $children; ?>
</ul>
</div>
<?php } } else {
$brother = wp_list_pages('depth=1&title_li=&child_of='.$post->post_parent.'&echo=0');
if ($brother) { ?>
<div id="subsubnav">
<ul>
<?php echo $brother; ?>
</ul>
</div>
<?php } } ?>
If anyone has an idea how to do this without identifying specific root pages, then be my guest in improving this script, but otherwise, it's working!
I've been looking for answer to this question as well
This topic has been closed to new replies.