FacetWP 3.6.8+ includes built-in support for WP-CLI.
WP-CLI is a PHP package that you install on your web server. Please visit wp-cli.org for details.
FacetWP provides 2 CLI commands:
wp facetwp index [--ids=<ids>] [--facets=<facets>]
wp facetwp purge [--ids=<ids>] [--facets=<facets>]
- ids (optional) — a comma-separated list of post IDs
- facets (optional) — a comma-separated list of facet names
Re-index the entire site:
wp facetwp index
Re-index a single post:
wp facetwp index --ids=42
Re-index facets named “make” and “model”:
wp facetwp index --facets=make,model
Re-index a post type named “cars”:
wp facetwp index --ids=$(wp post list --post_type=cars --format=ids | tr " " ",")
In the above example, we’re using WP-CLI’s
wp post list command. Post IDs are returned space-separated, so we use the
tr command to swap spaces with commas.
Purge the index table:
wp facetwp purge
Purge values for a facet named “year”:
wp facetwp purge --facets=year