1

I am making a theme with theme options but for customization, I have completed my theme options more than half. Suddenly I have triggered one problem and that is I have checked my wp_options DB I have noticed that there are separate rows for each and every option I have at least 20 options for my theme and each option have makes the new row record in wp_options table I want to know that is there is any short way to convert my whole of my options in an array and store that in one row.

2
  • Use customizer option like my_option[option1], my_option[option2] which store all values in my_option. Make serve you have selected customizer storage type option. Commented Aug 25, 2017 at 1:44
  • @maheshwaghmare can you give me any example. Commented Aug 25, 2017 at 5:35

1 Answer 1

1

It is trivial to store an array of options in WordPress — just pass an array to option functions. :)

The downside is that it will be stored in serialized form, which isn't friendly for SQL queries. That matters more for other APIs, such as meta data, than options.

Converting is up to you, you will need to adjust your code to work with and store an array.

2
  • is it also possible with codex.wordpress.org/Creating_Options_Pages example 3. I just want to know is it possible to make changes in it Commented Aug 19, 2017 at 7:40
  • Not sure on top of my head, Settings API is considered one of the more clunky APIs and it's quite typical for extensions to skip using it entirely.
    – Rarst
    Commented Aug 19, 2017 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.