Wp widget (WP-CLI)

Uit De Vliegende Brigade
Versie door Jeroen Strompf (overleg | bijdragen) op 27 aug 2022 om 17:20
(wijz) ← Oudere versie | Huidige versie (wijz) | Nieuwere versie → (wijz)
Naar navigatie springen Naar zoeken springen

wp widget manages widgets, including adding and moving them within sidebars.

  • Commando wp sidebar list kan van pas komen om de id's van de diverse sidebars te achterhalen
  • Ik heb het gevoel dat ik een commando mis om de specifieke waardes van de options van een widget te achterhalen. Zie ik iets over het hoofd?

Help-tekst:

$ wp help widget

NAME

  wp widget

DESCRIPTION

  Manages widgets, including adding and moving them within sidebars.

SYNOPSIS

  wp widget <command>

SUBCOMMANDS

  add             Adds a widget to a sidebar.
  deactivate      Deactivates one or more widgets from an active sidebar.
  delete          Deletes one or more widgets from a sidebar.
  list            Lists widgets associated with a sidebar.
  move            Moves the position of a widget.
  reset           Resets sidebar.
  update          Updates options for an existing widget.

  A [widget][1] adds content and features to a widget area (also called a [sidebar][2]).

  ---
  [1] https://developer.wordpress.org/themes/functionality/widgets/
  [2] https://developer.wordpress.org/themes/functionality/sidebars/

EXAMPLES

    # List widgets on a given sidebar
    $ wp widget list sidebar-1
    +----------+------------+----------+----------------------+
    | name     | id         | position | options              |
    +----------+------------+----------+----------------------+
    | meta     | meta-6     | 1        | {"title":"Meta"}     |
    | calendar | calendar-2 | 2        | {"title":"Calendar"} |
    +----------+------------+----------+----------------------+

    # Add a calendar widget to the second position on the sidebar
    $ wp widget add calendar sidebar-1 2
    Success: Added widget to sidebar.

    # Update option(s) associated with a given widget
    $ wp widget update calendar-1 --title="Calendar"
    Success: Widget updated.

    # Delete one or more widgets entirely
    $ wp widget delete calendar-2 archive-1
    Success: 2 widgets removed from sidebar.