Wordpress function: has_parentpage()

March 16th, 2009, 20:27H · Topics: Open Source, Programmierung · Print

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.


Download function


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: , , , ,

Leave a Reply

Your email address will not be published. Your photo in comments, use Gravatar
Please include http://
Note: XHTML is allowed.

Subscribe to this comment feed via RSS

Software-Development & Support

Hyte Software Developing great software, and enhancing your experience in using OpenSource-Software