Contextual Related Posts WP CLI commands (original) (raw)

Contextual Related Posts CLI (CRP-CLI) offers an efficient way to manage Contextual Related Posts via the command line. This tool is a part of Contextual Related Posts Pro from version 4.2.0 onward.

About WP-CLI

WP-CLI is a powerful set of command-line tools for managing WordPress installations. You can update plugins, configure multisite installations, and much more, all without using a web browser. For more information, visit the official WP-CLI website.

Getting Started with CRP-CLI

To begin using CRP-CLI, ensure that WP-CLI is installed and that you are running CRP Pro 4.2.0 or later. The CLI commands are accessed through the wp crp command. For a complete list of available commands, type wp crp in your command-line interface.

Table of Contents

CRP-CLI Command Tree

wp crp
├── cache
│   ├── clear     # Clear all cached related posts data
│   ├── enable    # Enable the CRP cache system
│   ├── disable   # Disable the CRP cache system
│   ├── warm      # Warm up cache by pre-generating related posts
│   ├── keys      # Show cache keys for posts
│   └── cleanup   # Remove expired cache entries
├── db
│   ├── status           # Show database migration and index status
│   ├── migrate-meta     # Migrate from crp_post_meta to _crp_* keys
│   └── rollback-meta    # Rollback migration - will be deprecated in the next version
├── tables
│   ├── create    # Create custom tables for CRP Pro
│   ├── drop      # Drop custom tables
│   ├── status    # Show custom tables status
│   └── index     # Index posts into custom tables
├── tables indexes
│   ├── create    # Create FULLTEXT indexes for custom tables
│   ├── delete    # Delete FULLTEXT indexes from custom tables
│   ├── recreate  # Recreate FULLTEXT indexes for custom tables
│   └── status    # Check status of FULLTEXT indexes
├── related      # Show related posts for a specific post (requires post ID)
├── settings
│   ├── export    # Export plugin settings to file
│   ├── import    # Import plugin settings from file
│   ├── get       # Get a specific setting value
│   └── set       # Set a specific setting value
└── status       # Show comprehensive status of all CRP components

Available Commands

All commands are prefixed with wp crp. For example: wp crp cache clear

Cache Commands (wp crp cache)

Manage the plugin’s cache system.

wp crp cache clear

Clear all cached related posts data.

Options:

Examples:

wp crp cache clear
wp crp cache clear --network
wp crp cache clear --verbose

wp crp cache enable

Enable the CRP cache system.

Options:

Examples:

wp crp cache enable
wp crp cache enable --type=html
wp crp cache enable --network

wp crp cache disable

Disable the CRP cache system.

Options:

Examples:

wp crp cache disable
wp crp cache disable --type=html
wp crp cache disable --network

wp crp cache warm

Warm up the cache by pre-generating related posts data.

Options:

Examples:

wp crp cache warm
wp crp cache warm --post-id=123
wp crp cache warm --network

wp crp cache keys

Show cache keys for posts.

Options:

Examples:

wp crp cache keys
wp crp cache keys --post-id=123
wp crp cache keys --post-id=1,2,3
wp crp cache keys --verbose

wp crp cache cleanup

Clean up expired cache entries.

Options:

Examples:

wp crp cache cleanup
wp crp cache cleanup --dry-run
wp crp cache cleanup --network

Database Commands (wp crp db)

Manage database operations and migrations.

wp crp db migrate-meta

Migrate meta data from crp_post_meta array to individual _crp_* keys.

Options:

Examples:

wp crp db migrate-meta
wp crp db migrate-meta --dry-run
wp crp db migrate-meta --batch-size=50
wp crp db migrate-meta --network

wp crp db rollback-meta

Rollback meta migration from individual keys back to array format.

Note: This command will be removed in version v4.3.0. Not recommended for production sites.

Options:

Examples:

wp crp db rollback-meta --dry-run
wp crp db rollback-meta --batch-size=50
wp crp db rollback-meta --force

wp crp db status

Show database status and migration information.

Options:

Examples:

wp crp db status
wp crp db status --network
wp crp db status --format=json

Database Index Commands (wp crp db indexes)

Manage FULLTEXT indexes on core WordPress tables.

wp crp db indexes create

Create FULLTEXT indexes for related posts functionality.

Options:

Examples:

wp crp db indexes create
wp crp db indexes create --dry-run

wp crp db indexes delete

Delete FULLTEXT indexes.

Options:

Examples:

wp crp db indexes delete --force
wp crp db indexes delete --dry-run

wp crp db indexes recreate

Recreate FULLTEXT indexes (delete then create).

Options:

Examples:

wp crp db indexes recreate
wp crp db indexes recreate --dry-run

wp crp db indexes status

Show FULLTEXT index status.

Examples:

wp crp db indexes status
wp crp db indexes status --format=json

Tables Commands (wp crp tables)

Manage custom tables for efficient content storage.

wp crp tables create

Create custom tables for CRP Pro.

Options:

Examples:

wp crp tables create
wp crp tables create --dry-run

wp crp tables drop

Drop custom tables.

Options:

Examples:

wp crp tables drop --force
wp crp tables drop --dry-run

wp crp tables status

Show the custom tables’ status.

Options:

Examples:

wp crp tables status
wp crp tables status --network
wp crp tables status --format=json

wp crp tables index

Index posts into custom tables.

Options:

Examples:

wp crp tables index
wp crp tables index --post-id=123
wp crp tables index --network

Tables Index Commands (wp crp tables indexes)

Manage FULLTEXT indexes on custom tables.

wp crp tables indexes create

Create FULLTEXT indexes for custom tables.

Options:

Examples:

wp crp tables indexes create
wp crp tables indexes create --network
wp crp tables indexes create --dry-run

wp crp tables indexes delete

Delete FULLTEXT indexes from custom tables.

Options:

Examples:

wp crp tables indexes delete
wp crp tables indexes delete --network
wp crp tables indexes delete --force

wp crp tables indexes recreate

Recreate FULLTEXT indexes for custom tables.

Options:

Examples:

wp crp tables indexes recreate
wp crp tables indexes recreate --network
wp crp tables indexes recreate --dry-run

wp crp tables indexes status

Show FULLTEXT index status for custom tables.

Options:

Examples:

wp crp tables indexes status
wp crp tables indexes status --network
wp crp tables indexes status --format=json

Show related posts for a specific post.

Arguments:

Options:

Examples:

wp crp related 123
wp crp related 123 --limit=5
wp crp related 123 --format=json
wp crp related 123 --url=http://example.com/site2

Settings Commands (wp crp settings)

Manage plugin settings.

wp crp settings export

Export plugin settings to a file.

Options:

Examples:

wp crp settings export
wp crp settings export --file=my-settings.json
wp crp settings export --format=php

wp crp settings import <file>

Import plugin settings from a file.

Arguments:

Options:

Examples:

wp crp settings import settings.json
wp crp settings import settings.json --merge
wp crp settings import backup.php --format=php

wp crp settings get <key>

Get a specific setting value.

Arguments:

Options:

Examples:

wp crp settings get cache
wp crp settings get cache --format=json

wp crp settings set <key> <value>

Set a specific setting value.

Arguments:

Options:

Examples:

wp crp settings set cache true --type=bool
wp crp settings set limit 10 --type=int
wp crp settings set post_types "post,page"

Status Command (wp crp status)

Show the comprehensive status of all CRP components.

Options:

Examples:

wp crp status
wp crp status --format=json
wp crp status --verbose

Global Options

All commands support these global options:

Multisite Support

Many commands support multisite operations with these options:

Priority order: --url--blog-id--network → current site

Network Administration

# Network-wide operations
wp crp cache clear --network
wp crp cache warm --network
wp crp cache enable --network
wp crp cache disable --network
wp crp db migrate-meta --network
wp crp db rollback-meta --network
wp crp db status --network
wp crp db indexes create --network
wp crp db indexes recreate --network
wp crp db indexes delete --network
wp crp db indexes status --network
wp crp tables status --network

Examples

Initial Setup

# Create custom tables
wp crp tables create

# Migrate meta data (if upgrading from older version)
wp crp db migrate-meta --dry-run
wp crp db migrate-meta

# Index existing content
wp crp tables index

# Warm up cache
wp crp cache warm

Regular Maintenance

# Clear cache
wp crp cache clear

# Index content
wp crp tables index --post-type=post --limit=1000

# Create database indexes
wp crp db indexes create

# Check overall status
wp crp status

Cache Management

# Clear specific post cache
wp crp cache clear --post-id=123

# Warm cache for recent posts
wp crp cache warm --recent=30

# Enable/disable cache types
wp crp cache enable --type=html
wp crp cache disable --type=posts

# Check cache keys
wp crp cache keys --post-id=123

Database Operations

# Migration workflow
wp crp db migrate-meta --dry-run
wp crp db migrate-meta
wp crp db status

# Index management
wp crp db indexes create
wp crp db indexes status

# Rollback if needed
wp crp db rollback-meta --dry-run
wp crp db rollback-meta

Custom Tables Management

# Setup custom tables
wp crp tables create
wp crp tables indexes create
wp crp tables status

# Content indexing
wp crp tables index --post-type=post
wp crp tables index --limit=1000

# Maintenance
wp crp tables indexes recreate
wp crp tables status --network

Error Handling

Most commands will:

Integration

These commands can be used in: