Upon theme activation I want to create an ‘URL’ key for the custom fields. Like in .
I know who to run functions when a theme is activated, I don’t know how to create this custom field key though. Any thoughts? I don’t want to be using custom meta boxes.
Those values are populated from the unique keys in the
*_postmeta
table, excluding keys that begin with an underscore (_
). If you want to pre-populate that key the add a value to the table under post ID0
. There is no way to pre-populate those that I am aware of besides to add a dummy meta_key/value to the*_postmeta
table.add_post_meta('0','URL','');
does not work, at least not when I try, so you need to write the SQL.That will create numerous entries in the database, however, unless you take further steps to avoid it.
I strongly advise against this hack.
Using a custom meta box is by far the cleaner solution, and I cannot guarantee that there are no negative consequences to adding a dummy key/value to
*_postmeta
. I highly recommend that you reconsider the custom meta box option.