Wordpress: Does a page have children?

/ Published in: PHP
Save to your folder(s)

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.

Copy this code and paste it in your HTML
  1. if ( get_children( $post->ID ) ) {
  2. // ...
  3. }

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

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.