Звучит глупо, ... но, задавая вопрос, я нашел решение:
<code>function delete_posts_title($partner) {
//delete all posts
$catposts = get_posts( array(
'category' => $partner['kategorie_id'],
'numberposts' => -1
) );
$i = 0;
foreach($catposts as $post) {
//exclude posts that are in these categories, too
if(!in_category( array(1,4145),$post->ID)) {
//echo "<pre>".$post->post_title." ". $i ."
"; wp_delete_post ($ post-> ID, false); ++ $ i;}} // удалить все подкатегории$ args = array ('child_of' => $ partner ['kategorie_id']); $ Categories = get_categories ($ args); foreach ($ category как $ category) {wp_delete_category ($ category-> term_id);}
}