I just created a conditional function for Wordpress to check, if the current page has a parent page (or if the page is a sub page). It works outside the main loop, and also inside. To use this function, you need WordPress 2.5 or higher.
Example usage
<?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <?php if ( has_parentpage() ): ?> <p> This page has a parent page. </p> <?php endif ?> <?php endwhile; ?>
Tags: function, opensource, php, themes, wordpress






