wordpress-database

Implement custom WordPress tables and queries using $wpdb, WP_Query, and dbDelta.

1|Updated Apr 19, 2026
One-click install
npx skills add https://github.com/iwritec0de/wp-dev --skill wordpress-database
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wordpress-database
Source: https://github.com/iwritec0de/wp-dev/tree/main/skills/wordpress-database
Command: npx skills add https://github.com/iwritec0de/wp-dev --skill wordpress-database

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

WordPress developers need dependable patterns for creating and maintaining custom database tables, performing migrations, and executing efficient queries. This skill consolidates best practices for working with $wpdb, WP_Query, and dbDelta, along with caching and multisite considerations.

Core Features & Use Cases

  • Create and evolve custom WordPress tables with dbDelta and versioning.
  • Build safe, efficient queries using $wpdb and WP_Query, including meta and tax queries.
  • Manage schema migrations and multisite deployments with proper safeguards and performance enhancements.
  • Learn advanced patterns and references to optimize database interactions and debugging.

Quick Start

Create your first custom table by implementing dbDelta on plugin activation and verify migrations with version checks.

Frequently Asked Questions about wordpress-database

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create custom WordPress database tables on plugin activation?

Use dbDelta during plugin activation to create custom WordPress database tables by passing formatted SQL schema statements. This approach enforces safe schema creation and versioning patterns to ensure reliable plugin initialization without manual SQL execution.

What is the best way to write safe SQL queries in WordPress plugins?

Write safe SQL queries in WordPress plugins using the $wpdb->prepare method to escape user input and prevent injection vulnerabilities. This pattern ensures secure database interactions when executing custom queries against standard or custom tables.

How does dbDelta handle database schema migrations in WordPress?

dbDelta handles database schema migrations in WordPress by comparing existing table structures against new SQL definitions and applying necessary alterations. It automatically manages column additions and index updates while preserving existing data during version upgrades.

Can I use $wpdb and WP_Query for multisite database deployments?

Yes, you can use $wpdb and WP_Query for multisite database deployments by properly prefixing table names and applying safe query patterns. These tools manage site-specific data isolation and performance tuning across multisite network installations.

Why do my custom WordPress database queries fail without table prefixing?

Custom WordPress database queries fail without table prefixing because the system cannot locate un-prefixed tables in multisite or custom installations. Prefixing table names ensures reliable database connections and prevents data overlap across different sites.