• Heya,
    So I’m working on a website where the breadcrumb lies immediately beneath the horizontal navigation. Problem is, when there are sub pages to the navigation they lay over my breadcrumb instead of pushing it down.
    Now, I’m not seeking advice on how to better write this nav, I just want to know if there is a way to use PHP to check if the current page you are on has any children. Does anyone know?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you’re trying to detect sub-pages, you could try:

    <?php
        $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
        if ($children) { ?>
        // do something
      <?php } else { ?>
        // do something else
      <?php } ?>
    Thread Starter Spencer Hill

    (@ws5f3dj7)

    Sweet, thanks for the reply. I ended up using PHP count before you replied:

    <?php
    $children = get_pages('child_of='.$post->ID);
    
    if( count( $children ) != 0 ) {
    }
    ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to check if there are sub links?’ is closed to new replies.