Wp widget update (WP-CLI)

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen

Bewerk de instellingen voor bestaande widgets:

  • Merk op dat je een widget-id moet meegeven, maar niet een sidebar-id
  • De namen bij --attribute zijn de slugs, dus doorgaans met dashes en niet met underscores. Je kunt de namen ook achterhalen middels select distinct taxonomy from wp_term_taxonomy;
$ wp help widget update

NAME

  wp widget update

DESCRIPTION

  Updates options for an existing widget.

SYNOPSIS

  wp widget update <widget-id> [--<field>=<value>]

OPTIONS

  <widget-id>
    Unique ID for the widget

  [--<field>=<value>]
    Field to update, with its new value

EXAMPLES

    # Change calendar-1 widget title to "Our Calendar"
    $ wp widget update calendar-1 --title="Our Calendar"
    Success: Widget updated.

Voorbeeld - 2021.08.14

################################################################################
# Update widgets
################################################################################
#
wp widget update woocommerce_layered_nav-19 --title="Device"     --attribute="device"
wp widget update woocommerce_layered_nav-13 --title="Model"      --attribute="model"
wp widget update woocommerce_layered_nav-14 --title="Submodel"     --attribute="submodel"
wp widget update woocommerce_layered_nav-5  --title="Width (mm)"   --attribute="width-mm"
wp widget update woocommerce_layered_nav-6  --title="Depth (mm)"   --attribute="depth-mm"
wp widget update woocommerce_layered_nav-7  --title="Length (mm)"  --attribute="length-mm"
wp widget update woocommerce_layered_nav-16 --title="Product line" --attribute="product-line"

See also