Build a WordPress Plugin With Claude Code
Build a useful WordPress plugin with Claude Code, test it safely on a local WordPress site, activate it like a normal plugin, and refine it without writing the plugin manually.
Roadmap & Resources
Set Up a Safe Local WordPress Site
Use WordPress Studio, Not a Live Site
Do not build your first AI-generated plugin directly on a live production website.
IMPORTANT
Do not build your first AI-generated plugin directly on a live production website.
Use WordPress Studio instead. WordPress Studio is a free local WordPress environment for Mac and Windows. It lets you create and test plugins on your computer without risking a live site.
Install WordPress Studio & Create a Site
Download and install WordPress Studio. Then create a new local site.
Open WordPress Studio
https://developer.wordpress.com/studio/
For example:
My Plugin Test Site
Once the site is created, open the WordPress admin and make sure the basic website works.
Choose a Simple Plugin
For this guide, build something easy to understand:
Plugin
Announcement Bar Plugin
The plugin will let the site owner:
- enter announcement text
- optionally add a button
- choose the button URL
- enable or disable the bar
- show it at the top of the website
Example
Free shipping on orders over $50 — Shop Now
This is enough to demonstrate the complete WordPress plugin workflow.
Do not start with:
- memberships
- payments
- complex booking systems
- WooCommerce checkout modifications
- authentication
- large admin dashboards
Connect Claude Code & Build the Plugin
Open Claude Code
From the WordPress Studio site, open the project in your terminal or editor. Start Claude Code.
Before building, install or enable the official Build with WordPress plugin from the Claude Code plugin marketplace if available in your setup. The plugin is made by WordPress.com and provides WordPress-specific skills for themes, plugins, blocks and site development.
Open Build with WordPress Plugin
https://claude.com/plugins/build-with-wordpress
First Prompt — Review the Environment
Before building anything, use:
Review the WordPress Environment
Reviews the local WordPress site before any changes are made — WordPress and PHP versions, active theme, active plugins, the plugins directory, whether a similar plugin already exists, and any existing announcement-bar or notice code — then determines the safest structure for a new custom plugin without touching core, the active theme, or existing plugins. Finishes with a READY / NEEDS ATTENTION verdict.
Review this local WordPress site specifically for building a custom plugin. Do not change anything yet. Identify: - WordPress version - PHP version if available - active theme - active plugins - plugin directory - whether a plugin with a similar purpose already exists - any existing custom code related to announcement bars or site notices Determine the safest structure for a small custom WordPress plugin. Do not: - modify WordPress core - modify the active theme - disable existing plugins - install unnecessary dependencies Finish with: Plugin environment: READY / NEEDS ATTENTION
Build the Plugin
Then use:
Build the Simple Announcement Bar Plugin
Builds the complete Simple Announcement Bar plugin as a standalone WordPress plugin: an admin-configurable enable toggle, announcement text, and an optional button (text + URL), with a responsive frontend bar that only shows the button when both fields are set. Uses the WordPress Settings API, sanitizes saved settings, escapes frontend output, checks admin permissions, and follows current WordPress security and coding conventions — no core or theme edits, no page builder, no external API, no analytics, and no database table unless genuinely necessary. Inspects the generated PHP, explains the file structure, and explains how to activate and test it. Finishes with a READY / NOT READY verdict.
Build a complete WordPress plugin called: Simple Announcement Bar The plugin should add an optional announcement bar at the top of the public website. The WordPress administrator should be able to configure it from the admin area. Required settings: - Enable announcement bar: On / Off - Announcement text - Optional button text - Optional button URL Frontend behavior: - display the bar only when enabled - show the announcement text - show the button only when both button text and URL are provided - make the bar responsive - keep it readable on mobile - open normal internal links in the same tab WordPress requirements: - build this as a standalone plugin - follow current WordPress coding conventions - use WordPress Settings APIs where appropriate - sanitize saved settings - escape frontend output - check admin permissions - protect settings updates with the normal WordPress security mechanisms - use WordPress APIs instead of modifying database tables directly Keep styling intentionally simple so it works reasonably well with many themes. Do not: - edit WordPress core - modify the active theme - require a page builder - add an external API - add analytics - add a database table unless genuinely necessary - add unrelated functionality Create all plugin files inside the correct WordPress plugins directory. After implementation: - inspect the generated PHP for obvious errors - explain the plugin file structure - tell me how to activate and test it Do not deploy anything. Finish with: Plugin build: READY / NOT READY
Claude can create the plugin folder and complete WordPress plugin structure directly inside the local site; this is also the basic workflow WordPress demonstrates in its own Claude Code tutorial.
Open WordPress's Claude Code Plugin Tutorial
https://wordpress.com/blog/2026/02/12/build-wordpress-plugins-with-ai-claude-code/
Activate & Test the Plugin
Activate the Plugin
Go back to the WordPress admin.
Plugins Simple Announcement Bar Activate
WordPress's own Claude Code tutorial uses exactly this local build → Plugins → Activate workflow to verify the generated plugin.
Configure the Plugin
Open the settings page created by the plugin. Enter:
Announcement text
Get 20% off this weekend
Button text
Learn More
Button URL
https://example.com/offers
Enable the announcement bar and save. Now open the public site. The announcement should appear.
Test All States
Check:
Enabled — the announcement bar appears
Disabled — the announcement bar disappears
No button configured — the announcement still works without an empty button
Button configured — the correct text appears and the correct URL opens
Ask Claude to Test the Plugin
Use:
Review the Activated Plugin
Reviews the activated plugin end-to-end — no PHP errors, the settings page loads and saves, the enabled/disabled states work, announcement and button text are escaped, the button URL is sanitized, admin permissions and security checks are present, and neither WordPress core nor the active theme were touched — fixing only genuine problems without adding features. Finishes with a PASS / ISSUES REMAIN verdict.
Review the complete Simple Announcement Bar plugin after activation. Do not add new features. Verify: - plugin activation does not produce PHP errors - settings page loads - settings can be saved - disabled state hides the announcement - enabled state shows it - announcement text is escaped correctly - button text is escaped correctly - button URL is validated/sanitized appropriately - admin settings require appropriate permissions - WordPress security checks are present for settings updates - the plugin does not modify WordPress core - the plugin does not require the active theme to be edited Fix only genuine implementation problems. Finish with: Plugin test: PASS / ISSUES REMAIN
Polish & Prepare the Plugin
Improve the Admin & Frontend Experience
Once it works, improve the experience without turning the plugin into a huge product. Use:
Polish the Plugin
Polishes the admin settings screen (labels, descriptions, layout, save confirmation, validation) and the frontend bar (spacing, responsiveness, button alignment, long-text handling, mobile usability) while keeping the plugin lightweight — no animations, analytics, multiple bars, scheduling, targeting rules, user accounts, or premium functionality — preserving WordPress security and coding conventions.
Polish the Simple Announcement Bar plugin while keeping it lightweight. Improve the admin settings experience: - clear labels - short descriptions - sensible layout - clear Save button - useful validation - clear confirmation after saving Improve the frontend bar: - readable spacing - responsive layout - good button alignment - long text handling - mobile usability Keep styling minimal and compatible with a broad range of WordPress themes. Do not: - add animations - add analytics - add multiple announcement bars - add scheduling - add targeting rules - add user accounts - add premium functionality Preserve WordPress security and coding conventions.
Add Plugin Metadata
Before sharing the plugin, make sure the main plugin file includes appropriate metadata such as:
- Plugin Name
- Description
- Version
- Author
NOTE
Do not impersonate another plugin or company.
Run the Final Audit
Use:
Final Production-Readiness Audit
Runs a final production-readiness audit across WordPress integration (activation/deactivation, no core or unnecessary theme changes), settings (sanitized input, escaped output, permission checks, nonces), the frontend (enabled/disabled behavior, button logic, long text, mobile layout, theme conflicts), and code quality (WordPress APIs, no unneeded database tables or dependencies, no debug output or hard-coded localhost URLs, no PHP warnings) — without adding functionality or deploying anything. Finishes with a READY / NOT READY verdict, listing only remaining issues if not ready.
Run a final production-readiness audit of this WordPress plugin. Verify: ### WordPress integration - plugin activates successfully - plugin deactivates safely - no WordPress core files were modified - no theme files were modified unnecessarily ### Settings - settings save correctly - input is sanitized - output is escaped - admin permissions are checked - security/nonces are handled appropriately ### Frontend - announcement appears only when enabled - optional button behaves correctly - long text does not break the layout - mobile layout works - the plugin does not create obvious conflicts with the theme ### Code quality - WordPress APIs are used where appropriate - no unnecessary database tables exist - no external dependencies are required unnecessarily - no debugging output remains - no hard-coded localhost URLs remain - PHP does not produce important warnings/errors Do not add new functionality during this audit. Do not deploy anything automatically. Finish with: WordPress Plugin status: READY / NOT READY If NOT READY, list only the remaining important issues.
Test Before Using It on a Live Site
Final Pre-Production Checklist
Keep the first tests inside WordPress Studio. Once the plugin works correctly:
Deactivate and reactivate it Test the settings again Test desktop and mobile Create a ZIP of the plugin folder if you want to install it elsewhere Test it on a staging site before putting it on an important production website
NOTE
Do not assume that because a plugin works with one local theme it will behave perfectly with every WordPress setup.
Other Plugins You Can Build
Ideas to Try Next
Once someone understands this workflow, they can build simple plugins such as:
- FAQ block
- Testimonial block
- Custom CTA block
- Social links widget
- Reading-time indicator
- Simple table of contents
- Custom admin notice
- Maintenance notice
- Business-hours widget
- Custom shortcode
THE REAL LESSON
The real lesson is not: Build an announcement bar. It is: Describe a WordPress feature and let Claude Code turn it into an installable plugin.