Need a conditional to check for subpages
-
In the codex, it explains the following PHP will query the page for subnav and print it in a list:
<?php
if($post->post_parent)
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
if ($children) { ?>-
<?php echo $children; ?>
<?php } ?>
But in that same template, I also want to query the page, ask if there is subnav, and if so, use the “narrowcolumn” class instead of the “widecolumn” class. I realize I could use that same PHP snippet twice, but is there a shorter way of asking, “If there’s subnav, print this, if not, print this”?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Need a conditional to check for subpages’ is closed to new replies.