Dynamic Month & Year 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 Fall returns the wrong hemisphere on a staging server at midnight. Direct output, no browser, no cache in the way.

Since 1.8.0 the commands are always available: the plugin loads through Composer when present, with a PSR-4 fallback for source installs. Every command renders through the same date engine the blocks and shortcodes use.


wp dmyip shortcode <type>

Get the output of a specific shortcode.

Positional arguments:

  • <type> (required) – Shortcode type

Flags:

  • --offset=<n> (optional, int) – Signed year or month offset
  • --date=<YYYY-MM-DD> (optional, string) – Target date for countdown/age types; recurring types also accept MM-DD
  • --rule=<rule> (optional, string) – Recurring rule for occurrence types, like "last sunday of january" (added in 1.8.0)
  • --format=<format> (optional, string) – PHP date format
  • --case=<case> (optional, string) – none, title, upper, or lower (added in 1.8.0)
  • --rollover-day=<day> (optional, int) – Switch month output to the next month after this day (added in 1.8.0)

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 representative 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


wp dmyip test

Test representative shortcodes and verify they produce output.

wp dmyip test

Runs 7 representative shortcode checks (2026, September, September 12, 2026, Saturday, November 27, Fall, and a countdown) and reports pass/fail for each. Useful for verifying the plugin is working correctly after updates or migrations.


wp dmyip info

Display plugin version, the active site timezone, and the documentation link.

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?

On 1.8.0 or newer it shouldn’t: a PSR-4 fallback loads the plugin classes even without the vendor directory. If the command is missing, check that the plugin is active for the site WP-CLI is targeting (watch the –url flag on multisite) and that you’re on the current version.