<?php
function get_all_children($list, $array){
$child_sql = "SELECT DISTINCT wizard_posts.ID as id FROM wizard_posts WHERE wizard_posts.post_parent IN ('".$list."') AND wizard_posts.post_status = 'publish'";
$children = mysql_query($child_sql);
while($my_c = mysql_fetch_array($children)){
$parent_check .= $my_c['id'].',';
$my_exclude['items'][$my_c['id']] = $my_c['id'];
}
if(mysql_num_rows($children)!=0){
get_all_children($parent_check, $my_exclude);
}
return $my_exclude;
}
$my_exclude = array(
'items' => array(),
'parents' => array()
);
$my_sql = "SELECT post_id as id, meta_value as value FROM wizard_postmeta WHERE meta_key='sitemap_exclude' AND meta_value in ('exclude', 'exclude_child')";
$my_result = mysql_query($my_sql);
while($my_v = mysql_fetch_assoc($my_result)){
if($my_v['value']=='exclude_child'){
$my_exclude['items'][$my_v['id']] = $my_v['id'];
$my_exclude['parents'][$my_v['id']] = $my_v['id'];
} else {
$my_exclude['items'][$my_v['id']] = $my_v['id'];
}
}
foreach($my_exclude['parents'] as $parents){
$parent_list .= $parents.',';
}
get_all_children($parent_list, $my_exclude);
foreach($my_exclude['items'] as $items){
$my_exclude_list .= $items.",";
}
echo "<br>".$my_exclude_list."<br><br>";
?>
|