Modify Post Meta Field Values from WP Function

Custom meta field values sometimes need tweaking. Need to convert current post meta in your database? Need to perform a str_replace or preg_replace on a specific custom meta key on your WordPress site?

Here a quick function you can put in your wordpress theme’s functions.php file. Be careful before performing any of these search replaces on your fields!! Be sure you have a backup of your WP database. After saving your functions file, reload an admin dashboard page and your function will run (this function runs on admin_init). You only need to run it once, so be sure to comment it out when you are finished. This function will run on all posts in your current site.

This comma will delete a comma from the meta field _my_customfield.