Export & Import
The top-level export and import commands provide a quick way to migrate CodeSnippets data to and from a file. Unlike snippets push/pull, these are designed for one-off migrations rather than day-to-day Git workflows.
lps export
Section titled “lps export”Download all snippets from WordPress and write them to a single file.
lps export [output]| Argument | Default | Description |
|---|---|---|
output | snippets.json | Destination file path |
| Flag | Description |
|---|---|
--format / -f | Output format: json (default), php |
Examples:
# Export as JSONlps export
# Export as a PHP array (useful for including in a theme)lps export --format php snippets.phpPHP format example
Section titled “PHP format example”<?php/** * CodeSnippets Export * Generated by loopress CLI */
return [ 'price-formatter' => [ 'code' => <<<PHP// snippet code herePHP, 'active' => true, 'tags' => ['cli-import'], ],];lps import
Section titled “lps import”Upload snippets from a previously exported file back to WordPress.
lps import [input]| Argument | Default | Description |
|---|---|---|
input | (required) | Path to the source file |
Example:
lps import snippets.jsonWhen to use export/import vs snippets push/pull
Section titled “When to use export/import vs snippets push/pull”| Scenario | Recommended command |
|---|---|
| Day-to-day development, version control | snippets push / snippets pull |
| One-time migration between two sites | export + import |
| Backup before a big change | export snippets-backup.json |
| Sharing snippets as a PHP file | export --format php |