Wp option (WP-CLI)
Versie door Jeroen Strompf (overleg | bijdragen) op 29 jul 2022 om 08:21
wp option: beheer instellingen die in tabel wp_options
worden bijgehouden. Dit zijn object-onafhankelijke instellingen en je kunt dus niet de options opvragen die bij een specifieke pagina, post of product horen. Dit commando is een belangrijk stuk gereedschap om een site volledig via de shell te beheren. Temeer daar dit commando overweg kan met serialised data - Iets waar ik op SQL-niveau moeite mee heb.
wp option zelf doet weinig: De magie zit 'm in de subcommando's.
$ wp help option NAME wp option DESCRIPTION Retrieves and sets site options, including plugin and WordPress settings. SYNOPSIS wp option <command> SUBCOMMANDS add Adds a new option value. delete Deletes an option. get Gets the value for an option. list Lists options and their values. patch Updates a nested value in an option. pluck Gets a nested value from an option. update Updates an option value. See the [Plugin Settings API][1] and the [Theme Options][2] for more information on adding customized options. --- [1] https://developer.wordpress.org/plugins/settings/settings-api/ [2] https://developer.wordpress.org/themes/customize-api/ EXAMPLES # Get site URL. $ wp option get siteurl http://example.com # Add option. $ wp option add my_option foobar Success: Added 'my_option' option. # Update option. $ wp option update my_option '{"foo": "bar"}' --format=json Success: Updated 'my_option' option. # Delete option. $ wp option delete my_option Success: Deleted 'my_option' option.