Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have 3000 posts with that custom field name 'refer' and i need to change it to 'ref' for theme needs, instead of doing it manually i need a query or technique to change them all.

Question 1
I am trying to rename a custom field, from 'refer' to ref. what is the query needed to rename a custom filed. it would be better if its done using function.php(instead of doing in phpmyadmin).

Question 2
I also have a lot of unwanted custom fields which are need to be deleted, how should i go about. help me out guys.

share|improve this question
add comment

2 Answers

I found the answer

UPDATE `wp_postmeta` SET `meta_key` = 'ref' WHERE `meta_key` = 'refer'

use this part in your SQL

Reference

share|improve this answer
    
Ohh, you never mentioned you got 3000 posts with that custom field! Glad you found the answer! –  Rutwick Gangurde Oct 16 '11 at 7:25
    
FYI: No need for the backticks around the table/column names. –  t31os Oct 16 '11 at 10:45
add comment

If you're trying to delete a post's custom field, then please edit your post, select 'Custom Fields' from the screen options, and scroll to the bottom, below the post editor. You'll find all your custom fields listed out there, you can edit their name, and change their values too. But ONLY those which you've added while adding / editing the post. Not the ones that WP creates for each post. DO NOT DELETE THE CUSTOM FIELDS WHICH YOU HAVEN'T ADDED!

share|improve this answer
    
i already have 3000 posts with that custom field name 'refer' and i need to change it to 'ref' for theme needs, instead of doing it manually i need a query or technique to change them all. –  Ezhil Oct 16 '11 at 4:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.