[wp-hackers] uninstall post meta with get_post issue

Ken Ken at adcSTUDIO.com
Mon Aug 30 20:08:50 UTC 2010


On 8/30/2010 4:02 PM, scribu wrote:
> On Mon, Aug 30, 2010 at 10:45 PM, Ken<Ken at adcstudio.com>  wrote:
>
>> I put this in uninstall.php in the root folder of my plugin. For some
>> reason it won't delete anything the meta of drafts. Am I doing something
>> wrong?
>>
>
> Instead of
>
> 'post_status' =>  null
>
> you should have
>
> 'post_status' =>  'any'
>
> Personally, I would do a single direct query:
>
> $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key IN ('foo', 'bar')"
> );
>
>


Thanks scribu,

Reading the codex I was wondering why post_type had 'any' but 
post_status was 'blank'. I tried reading the source for get_post but I 
got too far down the rabbit hole for it to make any sense to me! Your 
code works like a charm, thanks again. I'll update the codex.



More information about the wp-hackers mailing list