Last active
December 19, 2017 12:34
-
-
Save morgyface/238976d3f1b31213d89460e5988eecbd to your computer and use it in GitHub Desktop.
WordPress | Function | Check to see if a post has any children
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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