Question

Looking for advice for the best method to accomplish the following.

I have a custom page template with several custom fields/taxonomy.

The data needed for these custom fields actually resides in .txt files that are updated once a week. They are easily converted into .csv files. What would be the best and most secure method in getting this data into a custom page template, I figure I have 3 options.

Read the raw .txt or .csv files using custom php? Import the .csv into a separate database and grab the data from it? Import the data into the WordPress database?

Option 3 seems to be the best one, but I am completely unfamiliar with the wordpress database structure and the best way to go about this.

Was it helpful?

Solution

Unlikely that you will need intermediary database, from your description this is likely to be easy enough with bit of PHP and WP APIs.

  1. Create WP-Cron task (if you need automated recurrent import).

  2. Read data from flat files, for example with fgetcsv().

  3. Use wp_insert_post() for creating posts and custom field functions to add your data. This was recently covered in detail in WP insert post PHP function and Custom Fields question.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top