The updated script (v4.0) includes several new features for improved user experience:
- Configuration File Support: Stores settings in
.config/wp-export-config.json(in script directory) - Interactive Mode Selection: Choose between local and remote WordPress at startup
- Domain History: Remembers last 10 domains for quick selection
- SSH Favorites: Saves frequently used SSH connections with their WordPress paths
- Export Statistics: Tracks total exports and last export date
- Removed the
--remoteflag requirement - Now prompts users to select mode interactively:
- Option 1: Local WordPress
- Option 2: Remote WordPress (SSH)
- Shows recent domains when prompting for domain input
- Allows quick selection by number
- Automatically deduplicates and maintains order (most recent first)
- Limits to 10 most recent domains
- Saves SSH connections as favorites with their WordPress paths
- Shows favorites first when selecting SSH connections
- Allows quick selection with F1, F2, etc.
- Still shows SSH config hosts as numbered options
- Maintains up to 10 favorite connections
The script includes these new functions:
init_config()- Creates config directory and initial fileload_config()- Loads current configurationsave_config()- Saves configuration to diskadd_domain_to_history()- Adds domain to recent list (with deduplication)add_ssh_to_favorites()- Saves SSH connection and pathget_recent_domains()- Returns array of recent domainsget_ssh_favorites()- Returns SSH favorites with pathsupdate_export_stats()- Updates export count and timestamp
The config file at .config/wp-export-config.json (located in the same directory as the script) has this structure:
{
"recent_domains": [
"example.com",
"test.org",
"demo.net"
],
"ssh_favorites": [
{
"connection": "user@host.com",
"path": "/home/user/public_html"
}
],
"export_stats": {
"total_exports": 5,
"last_export": "2025-08-12T10:30:00Z",
"last_domain": "example.com"
}
}$ ./export_wp_posts.sh
=== WordPress Export Script v4.0 ===
Select export mode:
1) Local WordPress
2) Remote WordPress (SSH)
Enter choice (1 or 2): 2
Remote Mode Selected
This script exports all post types and custom permalinks via SSH.
SSH Connection Options:
SSH config hosts:
1. mysite-staging
2. client-prod
0. Enter custom connection
Select a host (1-2) or 0 for custom: 1$ ./export_wp_posts.sh
=== WordPress Export Script v4.0 ===
Select export mode:
1) Local WordPress
2) Remote WordPress (SSH)
Enter choice (1 or 2): 2
Remote Mode Selected
This script exports all post types and custom permalinks via SSH.
SSH Connection Options:
Recent SSH connections:
F1. mysite-staging (path: /home/user/public_html)
F2. client-prod (path: /var/www/html)
SSH config hosts:
1. mysite-staging
2. client-prod
0. Enter custom connection
Select an option (F1-F2, 1-2, or 0): F1
Using favorite: mysite-staging (path: /home/user/public_html)
Recent domains:
1. example.com
2. staging.example.com
3. client.com
Select a recent domain (1-3) or enter new domain: 1
Using: example.com- Faster repeated exports: No need to re-enter domains or SSH details
- Reduced errors: Pre-validated paths and connections
- Better organization: Track export history and statistics
- Improved workflow: Quick selection from favorites
- Persistent settings: Configuration survives between sessions
The script maintains full backwards compatibility:
- All original features work exactly as before
- Output format remains unchanged
- Directory structure is the same
- Can still be used without the config file (it will create one automatically)