Wp wc product cat get
Lees gegevens uit van individuele product_cat
-taxons:
$ wp help wc product_cat get NAME wp wc product_cat get DESCRIPTION Get a single item. SYNOPSIS wp wc product_cat get <id> [--id=<id>] [--context=<context>] [--fields=<fields>] [--field=<field>] [--format=<format>] OPTIONS <id> The ID for the resource. [--id=<id>] Unique identifier for the resource. [--context=<context>] Scope under which the request is made; determines fields present in response. [--fields=<fields>] Limit response to specific fields. Defaults to all fields. [--field=<field>] Get the value of an individual field. [--format=<format>] Render response in a particular format. --- default: table options: - table - json - csv - ids - yaml - count - headers - body - envelope ---
Voorbeelden
Gebruik bv. wp wc product_cat --user=4 list --per_page=2
om een taxon-id te achterhalen. Met dit taxon-id:
wp wc product_cat --user=4 get 44274 +-------------+------------------------------+ | Field | Value | +-------------+------------------------------+ | id | 44274 | | name | Alberka | | slug | alberka | | parent | 0 | | description | Alle widgets voor Alberka | | display | default | | image | null | | menu_order | 79 | | count | 8 | +-------------+------------------------------+
Count geeft het aantal producten aan, die met deze taxon zijn geassociëerd.
Verkrijg alleen het description-veld:
$ wp wc product_cat --user=4 get 44276 --field="description" Alle widgets voor Advanilla
--context
De flag --context
is niet beschreven op de site of via help
. Door een willekeurige waarde op te geven, krijg je meer info:
$ wp wc product_cat --user=4 get 44276 --field="description" --context="blub" Error: Invalid parameter(s): context {"status":400,"params":{"context":"context
Ik merk echter geen verschil in output - Vooral niet binnen het kader van het leading character-probleem wat hieronder genoemd wordt:
$ echo "»"$(wp wc product_cat --user=4 get 44277 --field="description" --context="view")"«" » Alle widgets voor A-C« $ echo "»"$(wp wc product_cat --user=4 get 44277 --field="description" --context="edit")"«" » Alle widgets voor A-C«
Probleem met leading character
Dit commando lijkt een leading ao
-karakter (line feed) toe te voegen aan de output.
Eerste voorbeeld:
echo "»"$(wp wc product_cat --user=4 get 44276 --field="description")"«" » All widgets for Advance«
Tweede voorbeeld:
$ i1=$(wp wc product_cat --user=4 get 18869 --field="description") $ echo "»"$i1"«" » Alle widgets voor AFX«
Gebruik van de flag --format
lijkt niet te helpen:
i1=$(wp wc product_cat --user=4 get 18869 --field="description") echo "»"$i1"«" i1=$(wp wc product_cat --user=4 get 18869 --field="description" --format="csv") echo "format=csv: »"$i1"«" i1=$(wp wc product_cat --user=4 get 18869 --field="description" --format="body") echo "format=body: »"$i1"«" i1=$(wp wc product_cat --user=4 get 18869 --field="description" --format="json") echo "format=json: »"$i1"«" i1=$(wp wc product_cat --user=4 get 18869 --field="description" --format="envelope") echo "format=envelope: »"$i1"«"
Oplossing (beter dan niets): Voeg |xargs
toe aan het wp-commando:
$ i1=$(wp wc product_cat --user=4 get 18869 --field="description"|xargs) $ echo "»"$i1"«" »gelukt!«