My situation is that I have a display plugin I want to use which can read and display information from custom fields but the information in the custom field is not in the correct format so the plugin’s output for that section will not be useful.
(The information in the database can’t be changed easily because it’s a large product catalog managed via CSV import)
I have considered a plan to ( for each custom post)
- Take the information from the various custom fields
- Process it into a suitable format for the plugin to display
- Store it in a new custom field in the Db (ready for use by the plugin)
I think I probably know how to do the above or could figure it out, that’s not the issue at the moment
The problem is that I am not sure when and by what method to run the eventual script.
The information in the various custom fields will be changing regularly ( with every CSV import/update ) and I want to keep my new custom field data up to date with it.
I have considered the following options for running the script …
- Have the script run automatically when the file is imported
- A button to press from the dashboard which would run the script to manipulate
- A Cron job.
- The problem with running the script on the CSV import is that it doesn’t cover a situation where the data was edited via the WordPress interface
- The problem with the button is that it’s manual and it could be forgotten.
- I don’t know much about crons and running a script like this but there are about 2000 ( custom ) post entries and I would rather they updated straight away so I can’t imagine that being good for performance if it was set to run every minute or something — or maybe that’s OK?
But maybe there’s a “WordPress Way” I don’t know about – in this scenario I’d imagine WordPress “noticing” if something had been changed in any of those custom fields; and then if it has been then it would run my script to aggregate the data for the custom field that the plugin would read. Is anything like this possible or if not how would be best to achieve this?