Skip to content

Instantly share code, notes, and snippets.

View vapvarun's full-sized avatar
👋
AI Developer & WordPress Expert. Building MCP servers & Plugins

Varun Kumar Dubey vapvarun

👋
AI Developer & WordPress Expert. Building MCP servers & Plugins
View GitHub Profile
@vapvarun
vapvarun / 01-diagnose-slow-postmeta-queries.sql
Last active February 23, 2026 19:09
WordPress wp_postmeta Custom Database Indexes — Diagnose, Add, Benchmark, and Automate
-- Diagnose slow wp_postmeta queries using EXPLAIN
-- Run these in phpMyAdmin or WP-CLI: wp db query < file.sql
-- Check the current indexes on wp_postmeta
SHOW INDEX FROM wp_postmeta;
-- Typical slow query: find posts by a custom field value
-- This is what WP_Query does with meta_query
EXPLAIN SELECT post_id
FROM wp_postmeta
@vapvarun
vapvarun / 01-install-redis-server.sh
Created February 23, 2026 19:12
Redis Object Cache for WordPress Step-by-Step (tweakswp.com)
sudo apt update
sudo apt install redis-server -y
# Verify Redis is running
sudo systemctl status redis-server
# Test connection
redis-cli ping
# Should respond: PONG
@vapvarun
vapvarun / 01-default-wordpress-htaccess.conf
Created February 23, 2026 19:15
WordPress .htaccess Tweaks for Security and Performance (tweakswp.com)
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@vapvarun
vapvarun / 01-transient-storage.sql
Created February 23, 2026 19:18
WordPress Transients: Find and Delete Expired Transients (tweakswp.com)
-- How WordPress stores transients in wp_options:
-- | option_name | option_value | autoload |
-- |------------------------------|----------------|----------|
-- | _transient_my_data | (serialized) | no |
-- | _transient_timeout_my_data | 1740211200 | no |
@vapvarun
vapvarun / 01-memory-limit.php
Created February 23, 2026 19:18
wp-config.php Tweaks: 15 Hidden Settings (tweakswp.com)
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
@vapvarun
vapvarun / 01-enable-wp-debug.php
Created February 23, 2026 19:19
WordPress Debug Log Guide (tweakswp.com)
// Enable WordPress debug mode
define( 'WP_DEBUG', true );
@vapvarun
vapvarun / 01-basic-syntax.sh
Created February 23, 2026 19:37
WP-CLI Search-Replace: The Complete Guide (tweakswp.com)
wp search-replace 'old-string' 'new-string' [table...] [--dry-run] [--precise] [--all-tables]
@vapvarun
vapvarun / 01-audit-wpcli.sh
Created February 23, 2026 19:37
Fix WordPress wp_options Autoload Bloat (tweakswp.com)
# Total size of all autoloaded data
wp db query "SELECT SUM(LENGTH(option_value)) AS autoload_size FROM wp_options WHERE autoload = 'yes';"
# Count of autoloaded options
wp db query "SELECT COUNT(*) AS autoload_count FROM wp_options WHERE autoload = 'yes';"
# Top 20 largest autoloaded options (the ones causing bloat)
wp db query "SELECT option_name, LENGTH(option_value) AS size_bytes, LEFT(option_value, 80) AS preview FROM wp_options WHERE autoload = 'yes' ORDER BY LENGTH(option_value) DESC LIMIT 20;"
@vapvarun
vapvarun / 01-check-version.sh
Created February 23, 2026 19:37
WPVivid Vulnerability CVE-2026-1357 Fix Guide (tweakswp.com)
# Check WPVivid version on a single site
wp plugin list --name=wpvivid-backuprestore --fields=name,version,status
# Check across all sites on a multisite network
wp site list --field=url | xargs -I {} wp plugin list --name=wpvivid-backuprestore --fields=name,version,status --url={}
@vapvarun
vapvarun / 01-count-revisions.sql
Created February 23, 2026 19:37
WordPress Post Revisions: Limit, Disable, Clean Up (tweakswp.com)
SELECT COUNT(*) FROM wp_posts WHERE post_type = 'revision';