Skip to content

How To Rename Custom Fields In WordPress

You can add and delete custom fields from post editor, but you can’t rename it from post editor UI. I’ll show you how to rename custom fields in WordPress.

One would tell you to rename all the custom fields by modifying your database tables, but we have another small trick to rename custom fields straight from your back-end.

Just run following code to your theme’s functions.php file:

global $wpdb;

$wpdb->query( "
UPDATE `wp_postmeta`
SET `meta_key` = 'NEW NAME'
WHERE `meta_key` = 'OLD NAME'
" );

In above code, replace new name and old name of your custom field, which you desire to rename.

[alert style=”red”]Note: Please remove this code immediately after saving your functions.php file. You only need to run this code once, there’s no need to keep this code in your theme.[/alert]

Leave a Reply

Your email address will not be published. Required fields are marked *