{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"never","basic_auth":false,"params":[],"results":{"codes":[]},"try":true},"next":{"description":"","pages":[]},"title":"Set your options","type":"basic","slug":"set-your-options","excerpt":"Only if needed!","body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"The missing `set_option`\"\n}\n[/block]\nThere are two ways to set options in your DB:\n+ `update_option` or `add_option` Wordpress function which have different uses (read [the add_option](http://codex.wordpress.org/Function_Reference/add_option) and [the update_option](http://codex.wordpress.org/Function_Reference/update_option) references)\n+ the new `set_option` TeaThemeOptions function which uses the transient API if asked and store options in DB without autoload.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Set option from the theme\"\n}\n[/block]\nSimply, use the function as follow:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\n$my_new_value = 'a new value';\\nTeaThemeOptions::set_option('my_value', $my_new_value);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\nIn the same way, writing `TeaThemeOptions::set_option` is too long. So we suggest you to add these lines in your `functions.php`, after the Tea Theme Options declaration:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nfunction _set_option($option, $value, $transient = false)\\n{\\n    TeaThemeOptions::set_option($option, $value, $transient);\\n}\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]\nYou can now set your options:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\n$my_new_value = 'a new value';\\n_set_option('my_value', $my_new_value);\",\n      \"language\": \"php\"\n    }\n  ]\n}\n[/block]","updates":[],"order":1,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"543f96e4051bdc0e00dfbf09","user":"542ea80e6b0eb6080066c9d5","category":{"sync":{"isSync":false,"url":""},"pages":["543249453ee609080061800c","543f96e4051bdc0e00dfbf09","54324b909afb2a080013cce0","54359c9e5e1b202000438229","54483f7bcfb4580800d5e2a8","546e2dfe0f33a80800f58518","56850afe65976e0d00001c9b"],"title":"How-to","slug":"how-to","order":2,"from_sync":false,"reference":false,"_id":"543264d3f2f806080098ad40","project":"5431c59ea55723080068e155","version":"5431c59ea55723080068e158","createdAt":"2014-10-06T09:45:55.706Z","__v":8},"githubsync":"","__v":10,"is_link":false,"createdAt":"2014-10-16T09:59:00.542Z","version":{"version":"1.0","version_clean":"1.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["5431c59ea55723080068e159","54325f53f2f806080098ad37","543264b1f2f806080098ad3e","543264c8f2f806080098ad3f","543264d3f2f806080098ad40","543264f42aca39080046d81e","5435bbf15e1b20200043834d","54e9cfb4f152c50d009b49ed"],"_id":"5431c59ea55723080068e158","project":"5431c59ea55723080068e155","__v":8,"createdAt":"2014-10-05T22:26:38.927Z","releaseDate":"2014-10-05T22:26:38.927Z"},"parentDoc":null,"project":"5431c59ea55723080068e155"}

Set your options

Only if needed!

[block:api-header] { "type": "basic", "title": "The missing `set_option`" } [/block] There are two ways to set options in your DB: + `update_option` or `add_option` Wordpress function which have different uses (read [the add_option](http://codex.wordpress.org/Function_Reference/add_option) and [the update_option](http://codex.wordpress.org/Function_Reference/update_option) references) + the new `set_option` TeaThemeOptions function which uses the transient API if asked and store options in DB without autoload. [block:api-header] { "type": "basic", "title": "Set option from the theme" } [/block] Simply, use the function as follow: [block:code] { "codes": [ { "code": "<?php\n\n$my_new_value = 'a new value';\nTeaThemeOptions::set_option('my_value', $my_new_value);", "language": "php" } ] } [/block] In the same way, writing `TeaThemeOptions::set_option` is too long. So we suggest you to add these lines in your `functions.php`, after the Tea Theme Options declaration: [block:code] { "codes": [ { "code": "<?php\n\nfunction _set_option($option, $value, $transient = false)\n{\n TeaThemeOptions::set_option($option, $value, $transient);\n}", "language": "php" } ] } [/block] You can now set your options: [block:code] { "codes": [ { "code": "<?php\n\n$my_new_value = 'a new value';\n_set_option('my_value', $my_new_value);", "language": "php" } ] } [/block]