AI-powered WordPress content management with PraisonAI integration and production-ready features
Project description
PraisonAI WPcli
AI-powered WordPress CLI tool for content management with precision editing capabilities.
Features
๐ NEW in v1.1.0: Production-Ready AI Integration!
AI-powered content generation with PraisonAI framework!
# Install with AI features
pip install praisonaiwp[ai]
# Set your OpenAI API key
export OPENAI_API_KEY="sk-..."
# Generate content
praisonaiwp ai generate "AI Trends 2025"
# Generate and auto-publish
praisonaiwp ai generate "AI Trends" \
--title "The Future of AI" \
--auto-publish \
--status publish
AI Features:
- โ PraisonAI Integration - Multi-agent content generation
- โ Production-Ready - API validation, retry logic, cost tracking
- โ Cost-Effective - Default gpt-4o-mini (~$0.0005 per 500-word post)
- โ Quality Control - Content validation, length checks, structure validation
- โ Auto-Publish - Direct WordPress publishing with one command
- โ Rate Limiting - Prevents API errors
- โ 58 Tests - 100% passing, production-ready
See PRAISONAI.md for complete AI documentation.
๐ NEW in v1.0.13: Universal WP-CLI Access!
ALL 1000+ WP-CLI commands now supported via the generic wp() method!
from praisonaiwp import SSHManager, WPClient
ssh = SSHManager('example.com', 'username')
client = WPClient(ssh, '/var/www/html')
# Use ANY WP-CLI command!
client.wp('cache', 'flush')
client.wp('db', 'export', 'backup.sql')
client.wp('plugin', 'install', 'akismet')
posts = client.wp('post', 'list', status='publish', format='json')
See GENERIC_WP_METHOD.md for complete documentation.
Core Features
- ๐ Universal WP-CLI - Direct access to ALL WP-CLI commands via
wp()method - ๐ฏ Convenience Methods - 48 wrapper methods with IDE autocomplete for common operations
- โก Fast - Auto-parallel mode for bulk operations (10x faster)
- ๐ Safe - Auto-backup, preview mode, dry-run capabilities
- ๐ Multi-Server - Manage multiple WordPress installations
- ๐ Smart - Auto JSON parsing, underscore-to-hyphen conversion
All Supported Features
๐ Post Management (6 methods)
create_post()- Create posts with metadataupdate_post()- Update post fieldslist_posts()- List with WP_Query filtersget_post()- Get post detailsdelete_post()- Delete posts (trash/force)post_exists()- Check post existence
๐ท๏ธ Post Meta (4 methods)
get_post_meta()- Get meta valuesset_post_meta()- Add meta fieldsupdate_post_meta()- Update metadelete_post_meta()- Remove meta
๐ Category/Term Management (8 methods)
set_post_categories()- Set categoriesadd_post_category()- Add categoryremove_post_category()- Remove categorylist_categories()- List all categoriesget_post_categories()- Get post categoriescreate_term()- Create new termdelete_term()- Delete termupdate_term()- Update term
๐ฅ User Management (9 methods)
list_users()- List all usersget_user()- Get user detailscreate_user()- Create new userupdate_user()- Update user fieldsdelete_user()- Delete user (with reassign)get_user_meta()- Get user metaset_user_meta()- Set user metaupdate_user_meta()- Update user metadelete_user_meta()- Delete user meta
โ๏ธ Option Management (3 methods)
get_option()- Get option valueset_option()- Set option valuedelete_option()- Delete option
๐ Plugin Management (3 methods)
list_plugins()- List all pluginsactivate_plugin()- Activate plugindeactivate_plugin()- Deactivate plugin
๐จ Theme Management (2 methods)
list_themes()- List all themesactivate_theme()- Activate theme
๐ท Media Management (1 method)
import_media()- Import media with metadata
๐ฌ Comment Management (6 methods)
list_comments()- List commentsget_comment()- Get comment detailscreate_comment()- Create commentupdate_comment()- Update commentdelete_comment()- Delete commentapprove_comment()- Approve comment
๐๏ธ Cache Management (2 methods)
flush_cache()- Flush object cacheget_cache_type()- Get cache type
โฑ๏ธ Transient Management (3 methods)
get_transient()- Get transient valueset_transient()- Set transient with expirationdelete_transient()- Delete transient
๐งญ Menu Management (4 methods)
list_menus()- List navigation menuscreate_menu()- Create new menudelete_menu()- Delete menuadd_menu_item()- Add menu item
๐ Core Commands (2 methods)
get_core_version()- Get WordPress versioncore_is_installed()- Check installation
๐พ Database (2 methods)
db_query()- Execute SQL querysearch_replace()- Search and replace in database
๐ Plus UNLIMITED via wp() Method!
Use ANY WP-CLI command directly:
# Database operations
client.wp('db', 'export', 'backup.sql')
client.wp('db', 'import', 'backup.sql')
client.wp('db', 'optimize')
# Plugin operations
client.wp('plugin', 'install', 'akismet')
client.wp('plugin', 'update', '--all')
# Theme operations
client.wp('theme', 'install', 'twentytwentyfour')
# Cron management
client.wp('cron', 'event', 'list', format='json')
client.wp('cron', 'event', 'run', 'wp_version_check')
# Core management
client.wp('core', 'update')
client.wp('core', 'verify-checksums')
# Media operations
client.wp('media', 'regenerate', '--yes')
# Export/Import
client.wp('export', author='admin')
client.wp('import', 'content.xml')
# ANY WP-CLI command works!
Total: 48 convenience methods + 1000+ commands via wp() ๐
Previous Updates (v1.0.2)
- ๐ SSH Config Support - Use
~/.ssh/confighost aliases for simplified connection management - ๐ง WP-CLI Auto-Installer - One-command WP-CLI installation with automatic OS detection (Ubuntu, Debian, CentOS, RHEL, Fedora, Alpine, macOS)
- ๐ WordPress Auto-Detection - Automatically find WordPress installations on your server with multiple search strategies
- โก UV Package Manager - 10-100x faster dependency management with modern tooling
- ๐ก๏ธ Enhanced Error Handling - Helpful error messages with installation instructions and troubleshooting
- ๐ Installation Verification - Automatic checks for WP-CLI and WordPress validity on startup
Installation
Using pip (Recommended)
# Core only (WordPress management)
pip install praisonaiwp
# With AI features (recommended)
pip install praisonaiwp[ai]
# With development tools
pip install praisonaiwp[dev]
# Everything
pip install praisonaiwp[all]
Using uv (10x faster!)
# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone and install
git clone https://github.com/MervinPraison/PraisonAI-WPcli.git
cd PraisonAI-WPcli
uv sync
# Run commands
uv run praisonaiwp init
From source
git clone https://github.com/MervinPraison/PraisonAI-WPcli.git
cd PraisonAI-WPcli
pip install -e ".[ai]" # With AI features
Quick Start
1. Initialize Configuration
praisonaiwp init
๐ก Pro Tips:
- Use SSH config alias (e.g.,
wp-prod) - connection details loaded automatically! - Press Enter for WordPress path - auto-detection will find it for you
- PHP binary is auto-detected, or specify for Plesk:
/opt/plesk/php/8.3/bin/php
๐ SSH Config Support:
PraisonAIWP automatically reads from ~/.ssh/config. If you have multiple hosts configured:
# ~/.ssh/config
Host wp-prod
HostName production.example.com
User prod_user
IdentityFile ~/.ssh/id_prod
Host wp-staging
HostName staging.example.com
User staging_user
IdentityFile ~/.ssh/id_staging
Host wp-dev
HostName localhost
User dev_user
Port 2222
IdentityFile ~/.ssh/id_dev
Just enter the host alias (e.g., wp-prod, wp-staging, or wp-dev) when prompted for hostname, and PraisonAIWP will automatically load all connection details from your SSH config!
Choosing Between Multiple Configs:
-
Each host alias is independent
-
Use
--serverflag to specify which server to use:praisonaiwp create "Post" --server production praisonaiwp create "Post" --server staging
-
Configure multiple servers in
~/.praisonaiwp/config.yaml:servers: # Method 1: Using ssh_host (recommended) production: ssh_host: wp-prod # Reference SSH config host wp_path: /var/www/html wp_cli: /usr/local/bin/wp # Method 2: Direct specification (traditional) staging: hostname: staging.example.com username: staging_user key_file: ~/.ssh/id_staging port: 22 wp_path: /var/www/staging wp_cli: /usr/local/bin/wp # Method 3: Mix both (direct values override ssh_host) dev: ssh_host: wp-dev username: custom_user # Override SSH config username wp_path: /var/www/dev wp_cli: /usr/local/bin/wp
New in v1.0.5: Use
ssh_hostto reference SSH config hosts! Connection details (hostname, username, key_file, port) are automatically loaded from~/.ssh/config. You can also specify connection details directly (traditional method) or mix both approaches - direct values always take precedence.
This will prompt you for:
- Server hostname - Can be IP, hostname, or SSH config alias (e.g.,
wp-prod) - SSH username - Auto-loaded from SSH config if using alias
- SSH key path - Auto-loaded from SSH config if using alias
- WordPress path - Press Enter to auto-detect, or specify manually
- PHP binary - Auto-detected, or specify custom path
2. Auto-Install WP-CLI (Optional)
If WP-CLI is not installed on your server:
# Automatically detect OS and install WP-CLI
praisonaiwp install-wp-cli -y
# Install with dependencies (curl, php)
praisonaiwp install-wp-cli --install-deps -y
# Custom installation path
praisonaiwp install-wp-cli --install-path /usr/bin/wp
# For Plesk servers
praisonaiwp install-wp-cli --php-bin /opt/plesk/php/8.3/bin/php -y
Supported Operating Systems:
- โ Ubuntu (18.04, 20.04, 22.04, 24.04)
- โ Debian (9, 10, 11, 12)
- โ CentOS (7, 8, 9)
- โ RHEL (7, 8, 9)
- โ Fedora (35+)
- โ Alpine Linux
- โ macOS (with Homebrew)
What it does:
- Detects your server's operating system
- Downloads WP-CLI from official source
- Tests the download
- Makes it executable
- Installs to system path
- Verifies installation
- Updates your config automatically
3. Auto-Detect WordPress (Optional)
If you don't know your WordPress installation path:
# Find all WordPress installations
praisonaiwp find-wordpress
# Interactive selection from multiple installations
praisonaiwp find-wordpress --interactive
# Find and update config automatically
praisonaiwp find-wordpress --update-config
# Find on different server
praisonaiwp find-wordpress --server staging
Search Strategies:
- Searches for
wp-config.phpin common directories - Checks predefined paths (
/var/www/html,/var/www/vhosts/*/httpdocs, etc.) - Verifies each installation (wp-config, wp-content, wp-includes)
- Extracts WordPress version
- Interactive selection for multiple installations
Example Output:
โ Found 2 WordPress installation(s)
โโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโณโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ # โ Path โ Version โ Components โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ 1 โ /var/www/html โ 6.4.2 โ config, content, includesโ
โ 2 โ /var/www/vhosts/example.com/httpdocsโ 6.3.1 โ config, content, includesโ
โโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโ
4. Create Posts
# Single post
praisonaiwp create "My Post Title" --content "Post content here"
# With author (NEW in v1.0.14)
praisonaiwp create "My Post" --content "Content" --author praison
praisonaiwp create "My Post" --content "Content" --author 1 # By user ID
# With categories
praisonaiwp create "My Post" --content "Hello" --category "Tech,AI"
# From file (auto-detects JSON/YAML/CSV)
praisonaiwp create posts.json
# Create 100 posts (automatically uses parallel mode!)
praisonaiwp create 100_posts.json
5. Update Posts
# Find and replace text
praisonaiwp update 123 "old text" "new text"
# Update specific line only
praisonaiwp update 123 "old text" "new text" --line 10
# Update 2nd occurrence only
praisonaiwp update 123 "old text" "new text" --nth 2
# Preview changes first
praisonaiwp update 123 "old text" "new text" --preview
# Update post fields directly (NEW in v1.0.14)
praisonaiwp update 123 --post-content "Full new content"
praisonaiwp update 123 --post-title "New Title"
praisonaiwp update 123 --post-status draft
# Update categories
praisonaiwp update 123 --category "Tech,AI"
6. Find Text
# Find in specific post
praisonaiwp find "search text" 123
# Find across all posts
praisonaiwp find "search text"
# Find in pages
praisonaiwp find "search text" --type page
7. List Posts
# List all posts
praisonaiwp list
# Search posts (NEW in v1.0.14)
praisonaiwp list --search "Pricing"
praisonaiwp list -s "keyword"
# List pages
praisonaiwp list --type page
# List drafts
praisonaiwp list --status draft
# Limit results
praisonaiwp list --limit 10
8. Manage Categories
# List all categories
praisonaiwp category list
# Search for categories
praisonaiwp category search "Technology"
# List categories for a specific post
praisonaiwp category list 123
# Set categories (replace all)
praisonaiwp category set 123 --category "Tech,AI"
# Add categories (append)
praisonaiwp category add 123 --category "Python"
# Remove categories
praisonaiwp category remove 123 --category "Uncategorized"
# Create post with categories
praisonaiwp create "My Post" --content "Hello" --category "Tech,AI"
# Update post categories
praisonaiwp update 123 --category "Tech,Python"
9. AI Content Generation (NEW in v1.1.0)
# Set your OpenAI API key (required)
export OPENAI_API_KEY="sk-..."
# Generate content (creates draft)
praisonaiwp ai generate "AI Trends 2025"
# Generate with custom title
praisonaiwp ai generate "AI Trends" --title "The Future of AI"
# Generate and auto-publish
praisonaiwp ai generate "AI Trends" \
--title "The Future of AI" \
--auto-publish \
--status publish
# Verbose mode (see generation details)
praisonaiwp ai generate "AI Trends" --verbose
# Use different server
praisonaiwp ai generate "AI Trends" --server production
AI Features:
- Powered by PraisonAI multi-agent framework
- Default model: gpt-4o-mini (cost-effective)
- Automatic content validation
- Cost tracking
- Retry logic with exponential backoff
- Rate limiting to prevent API errors
Programmatic Usage:
from praisonaiwp.ai.integration import PraisonAIWPIntegration
from praisonaiwp.core.ssh_manager import SSHManager
from praisonaiwp.core.wp_client import WPClient
# Setup
ssh = SSHManager(hostname="example.com", username="user", key_file="~/.ssh/id_rsa")
wp_client = WPClient(ssh=ssh, wp_path="/var/www/html")
# Create AI integration
integration = PraisonAIWPIntegration(wp_client)
# Generate content
result = integration.generate(
topic="AI Trends 2025",
title="The Future of AI",
auto_publish=True
)
print(f"Post ID: {result['post_id']}")
print(f"Cost: ${result['cost']:.6f}")
print(f"Duration: {result['duration']:.2f}s")
See PRAISONAI.md for complete AI documentation.
AI Production Features
The AI integration includes enterprise-grade production features:
1. API Key Validation
- Validates OpenAI API key on initialization
- Clear error messages with setup instructions
- Format checking (must start with 'sk-')
2. Content Validation
- Length checks: Minimum 100 chars, maximum 10,000 chars (configurable)
- Paragraph structure: Requires at least 2 paragraph breaks
- Placeholder detection: Detects [INSERT], TODO, PLACEHOLDER text
- Skip option: Use
skip_validation=Trueto bypass
3. Cost Tracking
- Per-generation tracking: Track cost for each post
- Cumulative tracking: Total cost across all generations
- Model-specific pricing: Accurate pricing for gpt-4o-mini, gpt-4o, etc.
- Cost estimation: See estimated cost before generation
Example:
# Get cost summary
summary = integration.get_cost_summary()
print(f"Total cost: ${summary['total_cost']:.6f}")
print(f"Average cost: ${summary['average_cost']:.6f}")
4. Retry Logic with Exponential Backoff
- Automatic retries: 3 attempts on failure
- Exponential backoff: 1s, 2s, 4s delays
- Smart error handling: Distinguishes temporary vs permanent errors
- Configurable: Adjust max retries and delays
5. Rate Limiting
- Default limits: 10 requests per 60 seconds
- Automatic waiting: Waits when limit reached
- Configurable: Adjust limits per your needs
- Can be disabled: For unlimited usage
Example:
integration = PraisonAIWPIntegration(
wp_client,
enable_rate_limiting=True,
max_requests=10,
time_window=60
)
6. Structured Logging
- Generation metrics: Duration, cost, word count
- Progress tracking: Real-time generation status
- Error logging: Detailed error messages
- Verbose mode: Use
--verboseflag for details
7. Enhanced Result Metadata
Every generation returns comprehensive metadata:
{
'content': str, # Generated content
'post_id': int, # WordPress post ID (if published)
'cost': float, # Estimated cost in USD
'duration': float, # Generation time in seconds
'model': str, # Model used (e.g., 'gpt-4o-mini')
'metadata': {
'topic': str, # Original topic
'title': str, # Post title
'length': int, # Content length in chars
'word_count': int # Word count
}
}
Cost Comparison
| Model | Speed | Cost/500 words | Quality | Best For |
|---|---|---|---|---|
| gpt-4o-mini | 2-3s | $0.0005 | Good | Most use cases โ |
| gpt-4o | 5-8s | $0.011 | Excellent | Premium content |
| gpt-3.5-turbo | 1-2s | $0.0003 | Fair | High volume |
Configuration Options
integration = PraisonAIWPIntegration(
wp_client,
# Model settings
model='gpt-4o-mini', # Default model
verbose=0, # Verbosity (0-2)
status='draft', # Default post status
# Content validation
validate_content=True, # Enable validation
min_length=100, # Min chars
max_length=10000, # Max chars
# Rate limiting
enable_rate_limiting=True, # Enable limiter
max_requests=10, # Max requests
time_window=60, # Time window (seconds)
)
Test Coverage
- 58 tests - 100% passing
- Test categories: API validation, content validation, cost tracking, rate limiting, retry logic, integration, WordPress tools, CLI commands
- Production-ready: All edge cases covered
See PRAISONAI.md for detailed production features documentation.
Complete CLI Reference
praisonaiwp create - Create Posts
All Options:
praisonaiwp create [TITLE_OR_FILE] [OPTIONS]
Options:
--content TEXT Post content
--status TEXT Post status (publish, draft, private)
--type TEXT Post type (post, page)
--category TEXT Comma-separated category names/slugs
--category-id TEXT Comma-separated category IDs
--author TEXT Post author (user ID or login)
--excerpt TEXT Post excerpt
--date TEXT Post date (YYYY-MM-DD HH:MM:SS)
--tags TEXT Comma-separated tag names or IDs
--meta TEXT Post meta in JSON format: {"key":"value"}
--comment-status TEXT Comment status (open, closed)
--convert-to-blocks Auto-convert HTML to Gutenberg blocks (NEW in v1.0.17)
--server TEXT Server name from config
Examples:
# Basic post
praisonaiwp create "My Post" --content "Content here"
# With author and categories
praisonaiwp create "My Post" \
--content "Full content" \
--status publish \
--author praison \
--category "Tech,AI"
# With custom meta data (NEW in v1.0.15)
praisonaiwp create "My Post" \
--content "Content" \
--meta '{"custom_field":"value","price":"99.99"}'
# With excerpt and tags
praisonaiwp create "My Post" \
--content "Full content" \
--excerpt "Short summary" \
--tags "python,wordpress,automation"
# With custom date and comment status
praisonaiwp create "My Post" \
--content "Content" \
--date "2024-01-15 10:30:00" \
--comment-status closed
# All options combined
praisonaiwp create "My Post" \
--content "Full content" \
--status publish \
--type post \
--category "Tech,AI" \
--author praison \
--excerpt "Summary" \
--date "2024-01-15 10:00:00" \
--tags "python,ai" \
--meta '{"views":"0","featured":"yes"}' \
--comment-status open \
--server production
# From file
praisonaiwp create posts.json
# Auto-convert HTML to Gutenberg blocks (NEW in v1.0.17)
praisonaiwp create "My Post" \
--content "<h2>Title</h2><p>Content with <strong>HTML</strong></p>" \
--convert-to-blocks
praisonaiwp update - Update Posts
All Options:
praisonaiwp update POST_ID [FIND_TEXT] [REPLACE_TEXT] [OPTIONS]
Options:
--line INTEGER Update specific line number
--nth INTEGER Update nth occurrence
--preview Preview changes without applying
--category TEXT Comma-separated category names/slugs
--category-id TEXT Comma-separated category IDs
--post-content TEXT Replace entire post content
--post-title TEXT Update post title
--post-status TEXT Update post status (publish, draft, private)
--post-excerpt TEXT Update post excerpt
--post-author TEXT Update post author (user ID or login)
--post-date TEXT Update post date (YYYY-MM-DD HH:MM:SS)
--tags TEXT Update tags (comma-separated)
--meta TEXT Update post meta in JSON format
--comment-status TEXT Update comment status (open, closed)
--convert-to-blocks Auto-convert HTML to Gutenberg blocks (NEW in v1.0.17)
--server TEXT Server name from config
Examples:
# Find and replace
praisonaiwp update 123 "old text" "new text"
# Update specific line
praisonaiwp update 123 "old" "new" --line 10
# Update nth occurrence
praisonaiwp update 123 "old" "new" --nth 2
# Preview first
praisonaiwp update 123 "old" "new" --preview
# Update post fields directly
praisonaiwp update 123 --post-content "New full content"
praisonaiwp update 123 --post-title "New Title"
praisonaiwp update 123 --post-status draft
# Update excerpt and tags (NEW in v1.0.16)
praisonaiwp update 123 --post-excerpt "New summary"
praisonaiwp update 123 --tags "python,wordpress,automation"
# Update author and date
praisonaiwp update 123 --post-author praison
praisonaiwp update 123 --post-date "2024-01-15 10:00:00"
# Update custom meta
praisonaiwp update 123 --meta '{"views":"1000","featured":"yes"}'
# Update comment status
praisonaiwp update 123 --comment-status closed
# Update categories
praisonaiwp update 123 --category "Tech,AI"
# Combine multiple updates
praisonaiwp update 123 \
--post-title "Updated Title" \
--post-excerpt "New excerpt" \
--tags "python,ai" \
--meta '{"updated":"yes"}' \
--comment-status open
# Update content with HTML to blocks conversion (NEW in v1.0.17)
praisonaiwp update 123 \
--post-content "<h2>New Title</h2><p>Updated content</p>" \
--convert-to-blocks
praisonaiwp list - List Posts
All Options:
praisonaiwp list [OPTIONS]
Options:
--type TEXT Post type (post, page, all)
--status TEXT Post status (publish, draft, all)
--limit INTEGER Limit number of results
-s, --search TEXT Search posts by title/content
--server TEXT Server name from config
Examples:
# List all posts
praisonaiwp list
# Search (single word)
praisonaiwp list --search "Pricing"
praisonaiwp list -s "keyword"
# Search with spaces (use quotes)
praisonaiwp list --search "Test Post"
# List pages
praisonaiwp list --type page
# List drafts
praisonaiwp list --status draft
# Limit results
praisonaiwp list --limit 10
# Combine filters
praisonaiwp list --type post --status publish --limit 20
praisonaiwp find - Search Text
All Options:
praisonaiwp find PATTERN [POST_ID] [OPTIONS]
Options:
--type TEXT Post type to search
--server TEXT Server name from config
Examples:
# Find in specific post
praisonaiwp find "search text" 123
# Find across all posts
praisonaiwp find "search text"
# Find in pages
praisonaiwp find "search text" --type page
praisonaiwp category - Manage Categories
Subcommands:
list- List categories (all or for specific post)search- Search for categories by nameset- Set post categories (replace all existing)add- Add categories to post (append)remove- Remove categories from post
Examples:
# List all categories
praisonaiwp category list
# Search categories
praisonaiwp category search "Technology"
# List categories for a post
praisonaiwp category list 123
# Set categories (replace all)
praisonaiwp category set 123 --category "Tech,AI"
praisonaiwp category set 123 --category-id "1,2,3"
# Add categories (append)
praisonaiwp category add 123 --category "Python"
# Remove categories
praisonaiwp category remove 123 --category "Uncategorized"
praisonaiwp ai - AI Content Generation (NEW in v1.1.0)
Subcommand:
praisonaiwp ai generate TOPIC [OPTIONS]
Options:
Options:
--title TEXT Post title (defaults to topic)
--status TEXT Post status (draft/publish/private)
--type TEXT Post type (post, page)
--category TEXT Comma-separated category names or slugs
--category-id TEXT Comma-separated category IDs
--author TEXT Post author (user ID or login)
--excerpt TEXT Post excerpt
--date TEXT Post date (YYYY-MM-DD HH:MM:SS)
--tags TEXT Comma-separated tag names or IDs
--meta TEXT Post meta in JSON format: {"key":"value"}
--comment-status TEXT Comment status (open, closed)
--auto-publish Automatically publish to WordPress
--verbose Verbose output
--server TEXT Server name from config
Examples:
# Basic generation (creates draft)
praisonaiwp ai generate "AI Trends 2025"
# With custom title
praisonaiwp ai generate "AI Trends" --title "The Future of AI"
# Auto-publish as draft
praisonaiwp ai generate "AI Trends" \
--title "The Future of AI" \
--auto-publish
# Auto-publish as published post
praisonaiwp ai generate "AI Trends" \
--title "The Future of AI" \
--auto-publish \
--status publish
# With categories and tags
praisonaiwp ai generate "AI Trends" \
--category "Technology,AI" \
--tags "artificial-intelligence,machine-learning" \
--auto-publish
# With author and excerpt
praisonaiwp ai generate "AI Trends" \
--author praison \
--excerpt "Discover the latest AI trends" \
--auto-publish
# With custom meta fields
praisonaiwp ai generate "AI Trends" \
--meta '{"featured":"yes","views":"0"}' \
--auto-publish
# All options combined
praisonaiwp ai generate "AI Trends 2025" \
--title "The Future of AI" \
--status publish \
--type post \
--category "Technology,AI" \
--author praison \
--excerpt "Comprehensive AI trends analysis" \
--date "2024-01-15 10:00:00" \
--tags "ai,tech,trends" \
--meta '{"featured":"yes"}' \
--comment-status open \
--auto-publish \
--verbose
# Verbose mode (shows generation details, cost, duration)
praisonaiwp ai generate "AI Trends" --verbose
# Use specific server
praisonaiwp ai generate "AI Trends" --server production
Requirements:
- OpenAI API key:
export OPENAI_API_KEY="sk-..." - AI features installed:
pip install praisonaiwp[ai]
Features:
- Default model: gpt-4o-mini (~$0.0005 per 500-word post)
- Automatic content validation
- Cost tracking and estimation
- Retry logic (3 attempts with exponential backoff)
- Rate limiting (10 requests/60s by default)
- Production-ready error handling
See PRAISONAI.md for complete AI documentation.
Important Notes for AI Agents
โ ๏ธ Quoting Rules:
- Always quote arguments with spaces:
--search "multi word" - Single words don't need quotes:
--search keyword - Category names with commas:
--category "Tech,AI,Python"
โ Correct Usage:
praisonaiwp list --search "Test Post"
praisonaiwp create "My Title" --content "My content"
praisonaiwp update 123 --post-title "New Title"
praisonaiwp ai generate "AI Trends" --title "The Future"
โ Incorrect Usage:
praisonaiwp list --search Test Post # ERROR: Too many positional arguments
praisonaiwp create My Title --content My content # ERROR: Ambiguous
praisonaiwp ai generate AI Trends --title The Future # ERROR: Needs quotes
๐ง All Available Options Summary:
| Command | Key Options |
|---|---|
create |
--content, --status, --type, --category, --category-id, --author, --excerpt, --date, --tags, --meta, --comment-status, --convert-to-blocks, --server |
update |
--line, --nth, --preview, --category, --category-id, --post-content, --post-title, --post-status, --post-excerpt, --post-author, --post-date, --tags, --meta, --comment-status, --convert-to-blocks, --server |
list |
--type, --status, --limit, -s/--search, --server |
find |
--type, --server |
category |
Subcommands: list, search, set, add, remove with --category, --category-id |
ai generate |
--title, --status, --type, --category, --category-id, --author, --excerpt, --date, --tags, --meta, --comment-status, --auto-publish, --verbose, --server |
File Formats
JSON Format
[
{
"title": "Post Title",
"content": "<p>Post content</p>",
"status": "publish",
"type": "post"
}
]
YAML Format
- title: Post Title
content: <p>Post content</p>
status: publish
type: post
CSV Format
title,content,status,type
"Post Title","<p>Post content</p>",publish,post
Configuration
Configuration is stored in ~/.praisonaiwp/config.yaml:
version: "1.0"
default_server: default
servers:
default:
hostname: example.com
username: user
key_file: ~/.ssh/id_ed25519
port: 22
wp_path: /var/www/html
php_bin: /opt/plesk/php/8.3/bin/php
wp_cli: /usr/local/bin/wp
settings:
auto_backup: true
parallel_threshold: 10
parallel_workers: 10
ssh_timeout: 30
log_level: INFO
Advanced Usage
Line-Specific Replacement
When the same text appears multiple times but you only want to replace it at a specific line:
# Replace only at line 10
praisonaiwp update 123 "Welcome" "My Website" --line 10
Occurrence-Specific Replacement
Replace only the 1st, 2nd, or nth occurrence:
# Replace only the 2nd occurrence
praisonaiwp update 123 "Welcome" "My Website" --nth 2
Bulk Operations
Create 100 posts in ~8 seconds (vs 50+ seconds sequential):
# Automatically uses parallel mode for files with >10 posts
praisonaiwp create 100_posts.json
Troubleshooting
SSH Connection Issues
# Test SSH connection manually
ssh -i ~/.ssh/id_ed25519 user@hostname
# Fix key permissions
chmod 600 ~/.ssh/id_ed25519
chmod 600 ~/.ssh/config
WP-CLI Not Found
# Install WP-CLI automatically
praisonaiwp install-wp-cli -y
# Or check WP-CLI path manually
ssh user@hostname "which wp"
PHP MySQL Extension Missing
# Use Plesk PHP binary (edit config.yaml)
php_bin: /opt/plesk/php/8.3/bin/php
WordPress Path Not Found
# Auto-detect WordPress installation
praisonaiwp find-wordpress --update-config
AI Features Issues
API Key Not Set
Error: OPENAI_API_KEY not set.
Solution:
export OPENAI_API_KEY="sk-..."
# Add to ~/.bashrc or ~/.zshrc for persistence
AI Features Not Available
Error: AI features not available.
Install with: pip install 'praisonaiwp[ai]'
Solution:
pip install --upgrade praisonaiwp[ai]
Content Validation Failed
Error: Content validation failed:
- Content too short: 50 chars (minimum: 100)
Solutions:
# Option 1: Skip validation
praisonaiwp ai generate "Topic" --skip-validation
# Option 2: Adjust in code
integration = PraisonAIWPIntegration(wp_client, min_length=50)
Rate Limit Reached
WARNING: Rate limit reached (10 requests/60s). Waiting 15.3s...
Solutions:
# Increase limits
integration = PraisonAIWPIntegration(
wp_client,
max_requests=20,
time_window=60
)
# Or disable rate limiting
integration = PraisonAIWPIntegration(
wp_client,
enable_rate_limiting=False
)
Generation Failed After Retries
Error: Failed after 3 attempts: Connection timeout
Solutions:
- Check internet connection
- Verify OpenAI API status
- Try again later
- Check API key validity
Documentation
Core Documentation
- README.md - This file (main documentation)
- ARCHITECTURE.md - Technical architecture and design
- TESTING.md - Testing guide and best practices
- CHANGELOG.md - Version history and changes
AI Features (NEW in v1.1.0)
- PRAISONAI.md - Complete AI integration guide
- AI_DOCUMENTATION.md - Quick AI navigation
- RELEASE_NOTES_v1.1.0.md - v1.1.0 release notes
Development
# Clone repository
git clone https://github.com/MervinPraison/PraisonAI-WPcli.git
cd PraisonAI-WPcli
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=praisonaiwp
# Format code
black praisonaiwp/
# Lint
flake8 praisonaiwp/
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details.
Author
Praison
Links
- GitHub: https://github.com/MervinPraison/PraisonAI-WPcli
- Documentation: https://praisonaiwp.readthedocs.io
- PyPI: https://pypi.org/project/praisonaiwp
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file praisonaiwp-1.1.4.tar.gz.
File metadata
- Download URL: praisonaiwp-1.1.4.tar.gz
- Upload date:
- Size: 125.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b03f06f97e31581f9cd6013fffacff377e146027404016078d7d282f1f6f5da9
|
|
| MD5 |
7b7fd92cf5f8cdbfae69abf550cb8dd4
|
|
| BLAKE2b-256 |
4ffdcc9646256654a8e7918b2d79f5910b109596608fb321a8cf82c76c5a83dc
|
File details
Details for the file praisonaiwp-1.1.4-py3-none-any.whl.
File metadata
- Download URL: praisonaiwp-1.1.4-py3-none-any.whl
- Upload date:
- Size: 71.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da993c6143f986df94fbfffe999ba89068efba213d061d1551c638a631ee329c
|
|
| MD5 |
ce147b066d3808449d232c4123d98ce1
|
|
| BLAKE2b-256 |
0a3417f3d202886f5dd0acb232ef4297d96d6405d8f1c168b0f2e5dd0fd4fd03
|