Wp option get (WP-CLI)

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen

Get the complete contents of an option field:

  • If it concerns a field with serialized data, you will get that complete field. If you want to see part of the tree (subfields), use wp option pluck
  • I don't know how to use this command to find out whether an option field is autoloading or not.
$ wp help option get

wp option get

DESCRIPTION

  Gets the value for an option.

SYNOPSIS

  wp option get <key> [--format=<format>]

OPTIONS

  <key>
    Key for the option.

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

EXAMPLES

    # Get option.
    $ wp option get home
    http://example.com

    # Get blog description.
    $ wp option get blogdescription
    A random blog description

    # Get blog name
    $ wp option get blogname
    A random blog name

    # Get admin email.
    $ wp option get admin_email
    someone@example.com

    # Get option in JSON format.
    $ wp option get active_plugins --format=json
    {"0":"dynamically-dynamic-sidebar\/dynamically-dynamic-sidebar.php","1":"monster-widget\/monster-widget.php","2":"show-current-template\/show-current-template.php","3":"theme-check\/theme-check.php","5":"wordpress-importer\/wordpress-importer.php"}

Scalair value

E.g.:

> wp option get admin_email

info@example.com


> wp option get blogname

example.com

Serialised data

E.g.:

$ wp option get options_footer_links_1_0_link

array (
  'title' => 'Widgets GLX',
  'url' => 'http://en.s1/shop/glx/',
  'target' => '',
)

See also