Wp post meta get (WP-CLI)

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen

wp post meta get: Get the values for a particular meta object. In other words: What does the value field in table wp_postmeta say for this id and this key. This works for both scalars and serialized data.

$ wp help post meta get

NAME

  wp post meta get

DESCRIPTION

  Get meta field value.

SYNOPSIS

  wp post meta get <id> <key> [--format=<format>]

OPTIONS

  <id>
    The ID of the object.

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

  [--format=<format>]
    Get value in a particular format.
    ---
    default: var_export
    options:
      - var_export
      - json
      - yaml
    ---

Voorbeelden

Gebaseerd op het voorbeeld hieronder tav. wp post meta list:

wp post meta get 7 hero_text

<!--
First version - Until 2020.09.25
<h2>BlahBlah</h2>
-->
<!--
<h2>BlahBlah-2</h2>
-->
<h2>BlahBlah-3</h2>

Dit werkt ook voor serialised data:

wp post meta get 7 banner_pick_tool_link

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

Hoe je parameters kunt gebruiken in de argumenten: Alledrie de varianten werken:

id=7
bb=3
wp post meta get 7 buttonbars_3_buttonbar_title
wp post meta get 7 buttonbars_${bb}_buttonbar_title
wp post meta get $id buttonbars_${bb}_buttonbar_title

Zie ook