Updating Custom Fields
Now I’m making better use of the blog. I’ve realised that I can’t possibly remember the entire plugin, how it operates down to every function and procedure. I’ll be making notes in the form of blogging so we can all access more information in search results on this site.
I want to mention the Post Updating procedure but specifically Custom Fields/Post Meta. There is not really anything to it, nothing the user has to do to initiate such an event. Updating the Custom Fields for a post is all part of the Post Updating procedure however there is something important to be aware of. Changes to your Custom Field options on the Configuration page will have effects on posts when they are updated. Now, at this time Updating only happens when new data is available, in time we’ll need to apply updating when the Project Configuration changed in some way. If we make changes to the Custom Fields it will be reflected when they are updated i.e. if you keep the key/name the same but change what column of data populates that Custom Field then the data from that column would obviously overwrite the old value. You expect nothing less.
New Custom Fields
Adding a new Custom Field on Project Configuration will not currently caused that new Custom Field to be added to all posts already created by the project. As mentioned further up, the Updating process is only triggered by new data but if the user wants a new Custom Field to be added to all existing posts then that will need to change, an option I will need to add in time. Please request it if you require it.
What if you do have new data and an Update is carried out for a post? Well the new Custom Field that exists in your Configuration now but did not when the post was originally created, will be added to the post. The same function that updates a Custom Field also causes new one to be added. The function is update_post_meta but if a Custom Field/Post Meta does not exist when it is used, WordPress uses add_post_meta.
Key Point: as I write this the plugin does not yet run an update event for any reason other than new data existing for it. Engineer notes include this ability to be added.