• 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)
  • Thread Starter multiplier

    (@multiplier)

    I answered part of my question — this seems to work:

    <div id="content" <?php
    $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
    if ($children) { ?>
    class="narrowcolumn"
    <?php } ?>>

    But how do I construct the “then” part of the argument so that it uses “widecolumn” for certain pages?

Viewing 1 replies (of 1 total)
  • The topic ‘Need a conditional to check for subpages’ is closed to new replies.