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.
1 Answer
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.
-
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.– RarstCommented Aug 19, 2017 at 7:46
my_option[option1]
,my_option[option2]
which store all values inmy_option
. Make serve you have selected customizer storage type option.