Wp post meta patch (WP-CLI)

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen

wp post meta patch: Update velden met serialised content.

$ wp help post meta patch

NAME

  wp post meta patch

DESCRIPTION

  Update a nested value for a meta field.

SYNOPSIS

  wp post meta patch <action> <id> <key> <key-path>... [<value>] [--format=<format>]

OPTIONS

  <action>
    Patch action to perform.
    ---
    options:
      - insert
      - update
      - delete
    ---

  <id>
    The ID of the object.

  <key>
    The name of the meta field to update.

  <key-path>...
    The name(s) of the keys within the value to locate the value to patch.

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

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

Voorbeeld

$ wp post meta get 7 banner_pick_tool_link

array (
  'title' => 'Onze widget-Keuzehulp >',
  'url' => 'http://en.s1/widget-keuzehulp/',
  'target' => '',
)


$ wp post meta pluck 7 banner_pick_tool_link "title"

Onze widget-Keuzehulp >

$ wp post meta patch update 7 banner_pick_tool_link "title" "Our Widget Selection Tool >"

Success: Updated custom field 'banner_pick_tool_link'.

Zie ook