SponsoredHosinger Special Offer

WP+ WordPress Plugin Development

Build WordPress plugins from scratch: actions and filters, shortcodes, settings pages, custom post types, meta boxes, AJAX, REST endpoints, custom tables, cron and blocks.

What a WordPress Plugin Is

WordPress Plugin Development Lesson 1 of 27 ~2 min read

Overview

A WordPress plugin is a package of PHP code that adds a feature to a site — a contact form, a custom post type, an SEO panel — by hooking into WordPress at defined points rather than editing WordPress core files.

That last part is the rule that makes the whole ecosystem work. You never change a core file. Core updates would wipe your change out, and every other plugin assumes core is untouched. Instead, WordPress exposes thousands of hooks — named moments where it pauses and lets plugins run their code or change a value.

Plugin or theme?

Belongs in a pluginBelongs in a theme
Custom post types and taxonomiesLayout and visual design
Shortcodes and blocks that content depends onTemplate files for displaying content
Settings pages, forms, integrationsMenus locations and widget areas
REST API endpoints, scheduled tasksFonts, colours, image sizes for the design

The test: if a user switched themes tomorrow, would they lose something important? If yes, it belongs in a plugin.

How WordPress loads plugins

  1. wp-config.php runs and connects to the database.
  2. WordPress reads the active_plugins option — the list you control from the Plugins screen.
  3. It includes the main file of each active plugin, in alphabetical order.
  4. It fires plugins_loaded — every plugin is now available.
  5. The active theme's functions.php loads.
  6. It fires init, then parses the request, runs the query and renders the page.

Notice that your plugin's main file runs very early, before the theme and before WordPress knows what page was requested. That is why plugins rarely do things at load time. They register callbacks on hooks, and the work happens later, at the right moment.

Two kinds of hook

ActionFilter
PurposeDo something at a point in timeChange a value before WordPress uses it
Register withadd_action()add_filter()
Your callbackReturns nothingMust return the (possibly changed) value
ExampleSend an email when a post is publishedAdd text to the end of every post's content

Lessons 4 to 6 cover hooks in depth. Almost every other lesson in this path is "find the right hook, attach the right callback".

What you will build

Across this path you will build GDC Books, a plugin for managing a book catalogue. It grows a Book post type, a Genre taxonomy, ISBN and page-count fields, a settings page, a [gdc_books] shortcode, an AJAX "favourite" button, a REST API endpoint, a scheduled cleanup task, a widget and a block — every major plugin technique, all in one codebase.

Tip: The Plugin Developer Handbook and the Code Reference are the official documentation. Every function in this path is listed there with its full parameters.

Practice

  • Open Plugins → Installed Plugins on any site and pick one plugin. Read its main PHP file and find the first add_action() or add_filter() call.
  • List three features you would like to build, and decide which hooks they might need.
Create a free account to save which lessons you've finished. Save my progress