WP-CLI Commands

  • JNext lesson
  • KPrevious lesson
  • FSearch lessons
  • EscClear search

Base command: wp dmyip

The wp dmyip WP-CLI commands render any shortcode from the terminal, which sounds minor until you’re debugging why Summer returns the wrong hemisphere on a staging server at midnight. Direct output, no browser, no cache in the way.

Available when the modern loading path is active (requires vendor/autoload.php).


wp dmyip shortcode <type>

Get the output of a specific shortcode.

Positional arguments:

  • <type> (required) – Shortcode type

Flags:

  • --offset=<n> (optional, int) – Year offset
  • --date=<YYYY-MM-DD> (optional, string) – Target date for countdown/age types

Examples:

# Basic shortcodes
wp dmyip shortcode year
# 2026

wp dmyip shortcode month
# February

wp dmyip shortcode date
# February 18, 2026

wp dmyip shortcode weekday
# Tuesday

wp dmyip shortcode season
# Winter

# Year with offset
wp dmyip shortcode year --offset=5
# 2031

wp dmyip shortcode year --offset=-10
# 2016

# Countdown
wp dmyip shortcode daysuntil --date=2026-12-25
# 310

wp dmyip shortcode dayssince --date=2020-01-01
# 2240

# Age
wp dmyip shortcode age --date=1990-05-15
# 35

# Events
wp dmyip shortcode blackfriday
# November 28

wp dmyip shortcode cybermonday
# December 1

wp dmyip list

List all available shortcodes with descriptions.

Flags:

  • --format=<format> (default: table, options: table, csv, json, yaml)

Examples:

# Default table output
wp dmyip list

# JSON for scripting
wp dmyip list --format=json

# CSV for spreadsheets
wp dmyip list --format=csv

Output columns: shortcode, category, description, example


wp dmyip test

Test all shortcodes and verify they produce output.

wp dmyip test

Tests 17 core shortcode types and reports pass/fail for each. Useful for verifying the plugin is working correctly after updates or migrations.


wp dmyip info

Display plugin version, author, documentation link, and available commands.

wp dmyip info

Scripting Examples

Get values for shell scripts

YEAR=$(wp dmyip shortcode year)
DAYS=$(wp dmyip shortcode daysuntil --date=2026-12-31)
echo "Days remaining in $YEAR: $DAYS"

Verify after deployment

wp dmyip test && echo "All shortcodes working" || echo "FAILED"

Export shortcode list

wp dmyip list --format=json > shortcodes.json

Use in CI/CD

# Verify plugin shortcodes work in staging
wp dmyip test --url=https://staging.example.com

Quick answers to common questions:

What’s the practical use of the CLI commands?

Debugging and automation: verify shortcode output on a server directly, check locale behavior under different settings, and script content generation that needs rendered date values. wp dmyip shortcode year is the fastest sanity check the plugin has.

Why does the command say it’s unavailable?

The CLI surface requires the modern loading path (vendor/autoload.php present), which every normal install from WordPress.org has. The message appears on stripped dev copies missing the vendor directory.