Comment

13 Comments

  1. MarcusPublished: 3 years ago

    Hello,

    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: 3 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: 3 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: 3 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: 3 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: 5 months ago

    This is very helpful! Thank you for sharing.

    • IftekharPublished: 5 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.

  5. AnnPublished: 1 month ago

    Forgive my complete ignorance, but if I add this to my child theme’s functions.php, will I still see post meta data on my wordpress posts? Thank you!

    • IftekharPublished: 1 month ago

      Dear Ann, I never tested this code on any “child theme”. However, I don’t see any reason why it won’t work. Then again I would highly recommend you to use this on the “parent theme” if you can. As far as post “meta data” is concern, this code will delete only few meta data (defined by meta key i.e. ‘_edit_last’) and rest (if there is any) should remain as it is. Hope that helps. Thank you.

  6. DeePublished: 1 week ago

    rare sharing indeed. thanks

    • IftekharPublished: 5 days ago

      You are welcome 🙂

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.