1. MarcusPublished: 2 years ago


    I tried to put it in functions but got a blank screen for the webpage.

    What might I have done wrong? Is it outdated?

    You are right! This is exactly what I have been looking for!

    Is there something I could do to remove them by phpMyadmin by query instead of php. I have 500 000 rows…

    Thanks for the post!

    • IftekharPublished: 2 years ago

      Marcus, the only problem I see here is the name of my function (delete_post_meta) itself. I figured, that it is also the name of a native WP function. Perhaps, that could be an issue. However, I updated the snippet with new function name and changed it to “delete_useless_post_meta”. Also, please remember that you shouldn’t use “<?php” and “?>” tag while copying this snippet on your theme’s functions.php page. Can you try with this new snippet and let me know? Thanks.

  2. MarcusPublished: 2 years ago

    Thank you so much!

    It works great now! i am adding all kinds of stuff for it to delete.

    Is there a way to see which meta_key there is most rows of?

    I see that some have values, but I dont know if I need them i.e:

    – _downloadable (no) – I don’t have downloadable products
    – _virtual (no) – I am not using virtual products
    – _stock_status (yes) – I do not use stock at all cus we do drop shipping

    Are they safe to take away?

    Thank you!

    • IftekharPublished: 2 years ago

      It seems like you are using some sort of eCommerce plugin (WooCommerce most probably). In that case, I won’t recommend you to delete them. They are used and most probably required to store product meta data. If you really want to delete them, please do it at your own risk. You can use my function regardless to delete any meta key and their value. Hope that helps 🙂

      • MarcusPublished: 2 years ago

        Great Answer,

        Thanks a lot!

  3. Dipika DubeyPublished: 2 years ago

    Thanks a lot……explained very well .

    • IftekharPublished: 2 years ago

      You are welcome Dipika, I am glad that it was helpful for you 🙂

  4. DavidPublished: 2 months ago

    This is very helpful! Thank you for sharing.

    • IftekharPublished: 2 months ago

      Hello David, I am happy to know that you find this snippet to be useful. You are welcome and thank you for stopping by.

Leave a Reply

Note: Convet HTML, PHP, JavaScripts from Postable, before posting from comment section.
License: By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution. Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.