Skip to content

Instantly share code, notes, and snippets.

@lukaszklis
lukaszklis / gist:1247306
Last active July 29, 2022 11:25
WordPress: check if a current page has children, if so display them, if not display all pages on the same level as current page
<?php
// Your functions.php content
function has_children() {
global $post;
$pages = get_pages('child_of=' . $post->ID);
return count($pages);