Skip to content

Instantly share code, notes, and snippets.

@morgyface
Last active December 19, 2017 12:34
Show Gist options
  • Select an option

  • Save morgyface/238976d3f1b31213d89460e5988eecbd to your computer and use it in GitHub Desktop.

Select an option

Save morgyface/238976d3f1b31213d89460e5988eecbd to your computer and use it in GitHub Desktop.
WordPress | Function | Check to see if a post has any children
<?php
// True or false function to check for child pages
function has_children() {
global $post;
$children = get_pages(
array(
'child_of' => $post->ID
)
);
if( count( $children ) == 0 ) {
return false;
} else {
return true;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment