I have the site in WordPress where I used the custom fields, but now I want to use that custom field as post tag automatically.
Can anyone have any idea?
migrated from stackoverflow.com Sep 26 '11 at 12:13
This question came from our site for professional and enthusiast programmers.
To convert the old custom fields, you can write a plugin that, on activation, fetches all the posts with your custom field name and converts them to tags with the handy
First set up a few constants with your field names and post type.
Then the activation hook function:
And finally, you can hook into
Not sure if this is something you needed or a one time conversion.
As far as I am aware, this isn't possible to do automatically "out of the box". A quick Google and it looks like there are currently no plugins that will do the job for you.
However, I can't see any reason why a plugin couldn't be written to do this. You'll need to use the "save_post" hook, which will run every time a post is saved/updated, check the custom field and apply it as a tag.
Documentation on this particular hook is sparse, but it's mentioned here:
I ran into a similar question a while ago from someone asking how to automatically add keywords from the All-in-one SEO plugin as post tags (http://www.vidalquevedo.com/how-to-add-tags/#li-comment-62)
After I saw your question, I took that script I wrote and modified it to automatically add custom field values as post tags as well.
Here's the link to the script and post: http://www.vidalquevedo.com/wordpress-how-to-automatically-convert-custom-fields-to-post-tags/
Thanks, and please let me know if that helps!