Headless & CLI

WP-CLI Headless Command Reference & Operations Manual

Headless CLI execution: run imports, stream live logs, pause/resume sessions, manage cron workers, and execute automated bash pipelines.

Frexten Engineering Team
Updated 2026-11-20

Article Overview

  • Category: Command Line Interface, Automation & Headless DevOps
  • Audience: DevOps Engineers, System Administrators & CI/CD Pipeline Developers
  • Applies To: NextGen Smart Data Importer (Community Free & Enterprise Pro Editions)
  • Purpose: Complete command reference, syntax guide, and scripting handbook for managing NextGen Smart Data Importer via WP-CLI.

1. Executive Summary

While NextGen provides a modern React-powered admin interface, enterprise agencies and high-volume e-commerce merchants frequently require headless CLI automation:

  • Ingesting 250,000 products overnight via a Bash cron script.
  • Integrating catalog imports into automated GitHub Actions or Bitbucket CI/CD pipelines.
  • Streaming real-time server-side logs over SSH without browser memory limits.
  • Managing background micro-batch cron queues directly on dedicated servers.

NextGen registers a top-level wp nextgen command namespace with full argument parsing, ANSI color formatting, and progress bars.


2. Command Architecture Overview

Architecture Flowchart
flowchart TD User["DevOps / Server Terminal (SSH)"] --> Root["wp nextgen <subcommand>"] subgraph Commands["Core WP-CLI Subcommands"] Import["wp nextgen import <file> --entity=product"] List["wp nextgen list --status=running"] Log["wp nextgen log <import_id> --tail=50"] Rollback["wp nextgen rollback <import_id> --yes"] Queue["wp nextgen queue process --limit=50"] end Root --> Import Root --> List Root --> Log Root --> Rollback Root --> Queue

3. Core Command Reference

1. wp nextgen import

Execute a headless data import from any local file path:

bash
wp nextgen import <file-path> [options]

Options & Flags:

  • --entity=<type>: Target entity (post, page, product, user, or custom CPT). Default: post.
  • --mapping=<preset_id>: Use a saved mapping preset ID.
  • --update-existing=<field>: Match and update existing records by sku, id, slug, or title.
  • --status=<status>: Initial post status (publish, draft, pending). Default: publish.
  • --batch-size=<int>: Records per slice. Default: 50.
  • --dry-run: Simulate parsing and validation without writing changes to the database.

Example:

bash
wp nextgen import /var/www/feeds/products.csv --entity=product --update-existing=sku --status=publish

2. wp nextgen list

List historical and active import sessions:

bash
wp nextgen list [--status=<status>] [--format=<format>]

Example Output:

text
+-------------------+----------------+-----------+-----------+---------+---------------------+
| Import ID         | File Name      | Entity    | Processed | Status  | Started At          |
+-------------------+----------------+-----------+-----------+---------+---------------------+
| imp_6afe0ff4119d2 | catalog.csv    | product   | 997/1000  | failed  | 2026-11-20 04:12:00 |
| imp_6afe0ff8812a1 | blog_posts.csv | post      | 150/150   | complete| 2026-11-20 05:30:15 |
+-------------------+----------------+-----------+-----------+---------+---------------------+

3. wp nextgen log

Stream or inspect live session server logs:

bash
wp nextgen log <import_id> [--tail=<int>] [--follow]
  • --tail=<lines>: Output only the last N lines (e.g. --tail=100).
  • --follow / -f: Stream log output in real time as background workers process records.

4. wp nextgen rollback

Surgically revert an import session and clean up created posts and media files:

bash
wp nextgen rollback <import_id> [--yes]
  • --yes: Skip interactive confirmation prompt (essential for automated CI/CD scripts).

5. wp nextgen queue process

Trigger an immediate background image queue worker cycle:

bash
wp nextgen queue process [--limit=<int>]
  • Processes up to 50 (or specified limit) pending images from wp_nextgen_image_queue.

4. Production Bash Script Example: Nightly Inventory Sync

Save this script as /etc/cron.daily/sync_inventory.sh:

bash
#!/usr/bin/env bash
set -e

FEED_URL="https://cdn.supplier.com/feeds/daily_stock.csv"
LOCAL_FILE="/tmp/daily_stock.csv"
WP_PATH="/var/www/html"

echo "[$(date)] Fetching latest catalog feed..."
curl -s -o "$LOCAL_FILE" "$FEED_URL"

echo "[$(date)] Executing NextGen CLI Import..."
wp nextgen import "$LOCAL_FILE" \
    --path="$WP_PATH" \
    --entity=product \
    --update-existing=sku \
    --batch-size=100 \
    --allow-root

echo "[$(date)] Inventory sync completed successfully."
rm -f "$LOCAL_FILE"

5. Frequently Asked Questions (FAQ)

Q: Does WP-CLI execution hit PHP memory limits?

In CLI mode, PHP typically runs with memory_limit = -1 (unlimited). However, NextGen's Intelligent OOM Shield still flushes $wpdb->queries buffers automatically, ensuring memory consumption stays flat under 50 MB even when importing 500,000 rows.

Q: Can I run WP-CLI commands on WordPress Multisite networks?

Yes. Simply append the standard --url=example.com/subsite flag to target a specific subsite. NextGen automatically binds to that subsite's scoped database tables (wp_{blog_id}_nextgen_*).