在此结合两种方法:
$args = array(
\'post_type\' => \'attachment\',
\'numberposts\' => null,
\'post_status\' => null,
\'post_parent\' => $post_id
);
$attachments = get_posts($args);
if ($attachments) {
DELETE FROM wp_postmeta
WHERE post_id IN
(
SELECT id
FROM wp_posts
WHERE (post_type = \'book\')
)
;
}
};
然后:
DELETE FROM wp_posts WHERE (post_type = \'book\')
这应该给你的文章类型是附件和书籍的结合。。。