Created
February 5, 2013 19:41
-
-
Save antonioreyna/4717023 to your computer and use it in GitHub Desktop.
PHP: WordPress exclude selected page childs from parents
This file contains 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 | |
$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