I have the current SQL query which will delete all posts from a custom post type clothing
which are older than 2 days
delete
p,pm
from wp_posts p
join wp_postmeta pm on pm.post_id = p.id
where p.post_type = 'clothing'
and DATEDIFF(NOW(), p.post_date) > 2
The problem is that this query doesn't seem to delete the related metas such as related custom fields of the deleted posts.
My question is, how can I modify this code to also delete the relate metas from those posts?
Thanks
phpMyAdmin
. To be sure it will pass you can make three queries for the purpose. One to select post IDs for removal. Second DELETE FORM pm where post_id IN previously selected IDs and the last to delete posts where ID in the same selected IDs. - Rolice