WP-CLI Commands
Yoko Core provides custom WP-CLI commands under the yoko namespace.
Run commands using:
wp yoko <command> [options]
rel_tax
What It Does
Repairs relational taxonomy assignments for a configured CPT.
Options
cleanup(orrepair) positional command--cpt=<cpt_slug>required target post type
Examples
wp yoko rel_tax cleanup --cpt=resource
wp yoko rel_tax repair --cpt=resource
attach_pdf_links
What It Does
Scans content for local PDF links already in Media Library and attaches unattached PDFs to the linking post.
Behavior:
- Supports direct .pdf URLs and PDF attachment permalinks.
- Only attaches when post_parent is 0.
- Skips files already attached to another post.
- Dry run by default; pass --apply to write changes.
Options
--post_type=<post_type[,post_type]>--post_status=<status[,status]>--post_id=<id[,id]>--limit=<number>--offset=<number>--batch_size=<number>--apply--dry-run--verbose
Examples
wp yoko attach_pdf_links --dry-run
wp yoko attach_pdf_links --post_type=page --post_status=publish --verbose
wp yoko attach_pdf_links --post_id=3512 --apply
create_missing_pdf_attachments
What It Does
Scans local .pdf URLs and creates missing attachment records when files exist in uploads but are not registered in Media Library.
Behavior:
- Creates attachment post records.
- Sets attachment guid to the resolved uploads URL.
- Dry run by default; pass --apply to write changes.
Options
--post_type=<post_type[,post_type]>--post_status=<status[,status]>--post_id=<id[,id]>--limit=<number>--offset=<number>--batch_size=<number>--apply--dry-run--verbose
Examples
wp yoko create_missing_pdf_attachments --dry-run
wp yoko create_missing_pdf_attachments --post_type=page --post_status=publish --verbose
wp yoko create_missing_pdf_attachments --post_id=3512 --apply
replace_pdf_urls_with_attachment_permalinks
What It Does
Replaces direct local .pdf URLs with attachment permalinks.
Options
--post_type=<post_type[,post_type]>--post_status=<status[,status]>--post_id=<id[,id]>--limit=<number>--offset=<number>--batch_size=<number>--apply--dry-run--verbose
Examples
wp yoko replace_pdf_urls_with_attachment_permalinks --dry-run
wp yoko replace_pdf_urls_with_attachment_permalinks --post_id=3512 --verbose
wp yoko replace_pdf_urls_with_attachment_permalinks --post_id=3512 --apply
replace_pdf_attachment_permalinks_with_urls
What It Does
Inverse of the previous command. Replaces PDF attachment permalinks with direct .pdf file URLs.
Options
--post_type=<post_type[,post_type]>--post_status=<status[,status]>--post_id=<id[,id]>--limit=<number>--offset=<number>--batch_size=<number>--apply--dry-run--verbose
Examples
wp yoko replace_pdf_attachment_permalinks_with_urls --dry-run
wp yoko replace_pdf_attachment_permalinks_with_urls --post_id=3512 --verbose
wp yoko replace_pdf_attachment_permalinks_with_urls --post_id=3512 --apply
Beaver Builder Support
When Beaver Builder is active, replacement commands process both:
- post_content
- _fl_builder_data
Details:
- URLs found only in Beaver Builder module settings are included as candidates.
- _fl_builder_data updates are done via WordPress meta APIs to preserve serialized integrity.
- Verbose output includes explicit lines when a candidate URL is found in Beaver Builder builder data.
- Summary output includes separate counts for _fl_builder_data rewrites.
Suggested Workflow
- Run with --dry-run --verbose.
- Review candidate replacements.
- Re-run with --apply.
- Re-run dry run to confirm no remaining replacements.
Troubleshooting
Unknown --post_id parameter
Update to the latest plugin code and clear opcode cache if enabled.
No candidates found, but page has Beaver Builder PDF buttons
Check:
- Beaver Builder is active.
- The page has _fl_builder_data.
- URLs are local to the same host.
- You are running with --verbose.
Local WP database connection issues
Confirm wp-config.php supports the local wrapper host override:
define( 'DB_HOST', getenv( 'WP_LOCAL_DB_HOST' ) ?: 'localhost' );