WP-CLI Commands

Validating The Site

This WP-CLI command  crawls the entire site for validation, or as much of it as you’d like.

$ wp amp validate-site
OptionDescription
–limit=<count>The maximum number of URLs to validate for each template and content type.
–include=<templates>Only validates a URL if one of the conditionals is true. For example, –include=is_tag,is_category
–forceForce validation of URLs even if their associated templates or object types do not have AMP enabled.

For example, if you want to limit this to 10 URLs for each type and only include tag and category templates:

$ wp amp validate-site --limit=10 --include=is_tag,is_category

For large sites, validation will take a long time without using the –limit option.

If you’re in Transitional mode (formerly ‘Paired’) and those templates are disabled, it won’t be possible to validate them without a flag.

For example, the “Categories” and “Tags” templates are disabled here in the “AMP Settings” menu:

The AMP Settings page, with some templates disabled

To force validating these templates, add the –force flag to the command:

$ wp amp validate-site --limit=10 --include=is_tag,is_category --force
WP-CLI command to validate the site

You’ll see a link at the bottom that shows all of the validated URLs.

Resetting Site Validation

If there was a change in the site, like if a plugin or theme was activated, it can help to reset the validation.

This ensures that there aren’t stale validation results, like:

The validated URLs with stale results

This command will delete the validation of all URLs:

$ wp amp reset-site-validation

Passing the –yes flag ensures that this doesn’t confirm ‘Are you sure you want to empty…’

$ wp amp reset-site-validation --yes