Wp option update (WP-CLI): verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
(Nieuwe pagina aangemaakt met '== wp option update == Updates an option value. Voorbeelden: <pre> wp option update blogname "$site_title" # Site title wp option update blogdescription "$slog...')
 
(4 tussenliggende versies door dezelfde gebruiker niet weergegeven)
Regel 1: Regel 1:
== wp option update ==
+
<code>wp option update</code>: Update an option value. When the option doesn't exist, it will be created (without warning or error):
  
Updates an option value. Voorbeelden:
+
<pre>
 +
$ wp help option update
 +
 
 +
NAME
 +
 
 +
  wp option update
 +
 
 +
DESCRIPTION
 +
 
 +
  Updates an option value.
 +
 
 +
SYNOPSIS
 +
 
 +
  wp option update <key> [<value>] [--autoload=<autoload>] [--format=<format>]
 +
 
 +
ALIAS
 +
 
 +
  set
 +
 
 +
OPTIONS
 +
 
 +
  <key>
 +
    The name of the option to update.
 +
 
 +
  [<value>]
 +
    The new value. If ommited, the value is read from STDIN.
 +
 
 +
  [--autoload=<autoload>]
 +
    Requires WP 4.2. Should this option be automatically loaded.
 +
    ---
 +
    options:
 +
      - 'yes'
 +
      - 'no'
 +
    ---
 +
 
 +
  [--format=<format>]
 +
    The serialization format for the value.
 +
    ---
 +
    default: plaintext
 +
    options:
 +
      - plaintext
 +
      - json
 +
    ---
 +
</pre>
 +
 
 +
== Bijwerken bestaande velden ==
  
 
<pre>
 
<pre>
 
wp option update blogname "$site_title"    # Site title
 
wp option update blogname "$site_title"    # Site title
 
wp option update blogdescription "$slogan" # Tagline
 
wp option update blogdescription "$slogan" # Tagline
 +
</pre>
 +
 +
== Bijwerken niet-bestaand veld ==
 +
 +
Als je dit commando toepast op een niet-bestaand veld, wordt dit veld gecreëerd - Handig!
 +
 +
Voorbeeld:
 +
 +
<pre>
 +
wp option update BlubBlubBlub "DitBestaatNiet"
 +
</pre>
 +
 +
De waarde voor ''autoload'' is standaard ''no''.
 +
 +
Voorbeeld inclusief waarde voor ''autoload'':
 +
 +
<pre>
 +
wp option update BlubBlubBlub "DitBestaatNiet" --autoload=yes
 +
</pre>
 +
 +
== Option autoload ==
 +
 +
Itt. tot wat de helptekst zegt, hoef je het argument voor ''autoload''; niet te quoten.
 +
 +
Voorbeeld:
 +
 +
<pre>
 +
wp option update BlubBlubBlub "DitBestaatNiet" --autoload=no
 +
</pre>
 +
 +
== Bijwerken met dezelfde waarde ==
 +
 +
Als je een option probeert bij te werken met dezelfde waarde als de oude waarde, krijg je een foutmelding:
 +
 +
<pre>
 +
$ wp option update BlubBlubBlub "DitBestaatNiet"
 +
 +
Error: Could not update option 'BlubBlubBlub'.
 
</pre>
 
</pre>
  

Versie van 29 jul 2022 08:41

wp option update: Update an option value. When the option doesn't exist, it will be created (without warning or error):

$ wp help option update

NAME

  wp option update

DESCRIPTION

  Updates an option value.

SYNOPSIS

  wp option update <key> [<value>] [--autoload=<autoload>] [--format=<format>]

ALIAS

  set

OPTIONS

  <key>
    The name of the option to update.

  [<value>]
    The new value. If ommited, the value is read from STDIN.

  [--autoload=<autoload>]
    Requires WP 4.2. Should this option be automatically loaded.
    ---
    options:
      - 'yes'
      - 'no'
    ---

  [--format=<format>]
    The serialization format for the value.
    ---
    default: plaintext
    options:
      - plaintext
      - json
    ---

Bijwerken bestaande velden

wp option update blogname "$site_title"    # Site title
wp option update blogdescription "$slogan" # Tagline

Bijwerken niet-bestaand veld

Als je dit commando toepast op een niet-bestaand veld, wordt dit veld gecreëerd - Handig!

Voorbeeld:

wp option update BlubBlubBlub "DitBestaatNiet"

De waarde voor autoload is standaard no.

Voorbeeld inclusief waarde voor autoload:

wp option update BlubBlubBlub "DitBestaatNiet" --autoload=yes

Option autoload

Itt. tot wat de helptekst zegt, hoef je het argument voor autoload; niet te quoten.

Voorbeeld:

wp option update BlubBlubBlub "DitBestaatNiet" --autoload=no

Bijwerken met dezelfde waarde

Als je een option probeert bij te werken met dezelfde waarde als de oude waarde, krijg je een foutmelding:

$ wp option update BlubBlubBlub "DitBestaatNiet"

Error: Could not update option 'BlubBlubBlub'.

Zie ook