Skip to content

Instantly share code, notes, and snippets.

@stuartduff
Created July 19, 2012 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartduff/3142942 to your computer and use it in GitHub Desktop.
Save stuartduff/3142942 to your computer and use it in GitHub Desktop.
WordPress remove sub pages of a parent page
<?php
$child_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent = 134 AND $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' ORDER BY $wpdb->posts.ID ASC");
$exclude = implode($child_ids,', ');
wp_list_pages('exclude=' . $exclude . '&title_li=');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment