Where to store plugin settings fields

It depends on how you are going to use the stored data.

If you want to run complex queries against the values, use a custom table with indexes optimized for those queries.

If you will always just fetch all the values for a given object, create a non-public custom post type, and store the data as post meta.

Do not store the data in a serialized string, like the options API does it. This is a nightmare when you want to change it per command line SQL, because the serialized format is PHP specific.

The “Settings API” imposes some very outdated markup, and the code for the registration and storage is rather counter-intuitive. I wouldn’t recommend to use it.

Leave a Comment