Only looping through pages that have children or subpages
I just figured out the answer to my own question. It works by counting the number of children pages using get_pages. Here is the working code: <?php $children = get_pages( array(‘child_of’ => $post->ID,’post_type’=>’custom-post-type-name’)); if( count( $children ) != 0 ) { ?> <h1><a href=”https://wordpress.stackexchange.com/questions/46090/<?php the_permalink(); ?>”><?php the_title(); ?></a></h1> <?php } else { } ?>