Skip to content

Instantly share code, notes, and snippets.

@antonioreyna
Created February 5, 2013 19:41
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 antonioreyna/4717023 to your computer and use it in GitHub Desktop.
Save antonioreyna/4717023 to your computer and use it in GitHub Desktop.
PHP: WordPress exclude selected page childs from parents
<?php
$toexclude = array(21, 23);
$parents = array(13);
$exclude_list = '';
foreach ($parents as $key => $parent) {
$args=array(
'child_of' => $parent
);
$pages = get_pages($args);
if ($pages) {
foreach ($pages as $page) {
$toexclude[]= $page->ID;
}
}
}
$exclude_list = implode(',', $toexclude);
$args=array(
'title_li' => '',
'depth' => 2,
'exclude' => $exclude_list
);
wp_list_pages($args);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment