Return to Snippet

Revision: 16821
at August 17, 2009 11:28 by cyberhobo


Updated Code
if ( get_children( $post->ID ) ) {
 // ...
}

Revision: 16820
at August 17, 2009 11:20 by cyberhobo


Initial Code
if ( get_children( $root_page_id ) ) {
 // ...
}

Initial URL
http://codex.wordpress.org/Function%5FReference/get%5Fchildren

Initial Description
There's no has\_children() function in WP 2.8.4, but get\_children() returns false if the post/page has no children, so it can serve the same purpose in a page template. 

Outside a page template you'd have to add a global declaration for the $post variable.

Initial Title
Wordpress: Does a page have children?

Initial Tags
template, post, page, wordpress

Initial Language
PHP