How To Create Your First WordPress Plugin

What is a plugin?

Difference between plugins and functions.php

How to create a WordPress plugin

  1. Create a plugin folder
  2. Set up plugin header
  3. Create plugin functionality
  4. Load plugin to WordPress
  5. Activate plugin

1. Create plugin folder

2. Set up plugin header

  • Plugin Name: (required) The name of your plugin, which will be displayed in the Plugins list in the WordPress Admin.
  • Plugin URI: The home page of the plugin, which should be a unique URL, preferably on your own website. This must be unique to your plugin. You cannot use a WordPress.org URL here.
  • Description: A short description of the plugin, as displayed in the Plugins section in the WordPress Admin. Keep this description to fewer than 140 characters.
  • Version: The current version number of the plugin, such as 1.0 or 1.0.3.
  • Requires at least: The lowest WordPress version that the plugin will work on.
  • Requires PHP: The minimum required PHP version.
  • Author: The name of the plugin author. Multiple authors may be listed using commas.
  • Author URI: The author’s website or profile on another website, such as WordPress.org.
  • License: The short name (slug) of the plugin’s license (e.g. GPLv2). More information about licensing can be found in the WordPress.org guidelines.
  • License URI: A link to the full text of the license (e.g. https://www.gnu.org/licenses/gpl-2.0.html).
  • Text Domain: The gettext text domain of the plugin. More information can be found in the Text Domain section of the How to Internationalize your Plugin page.
  • Domain Path: The domain path lets WordPress know where to find the translations. More information can be found in the Domain Path section of the How to Internationalize your Plugin page.
  • Network: Whether the plugin can only be activated network-wide. Can only be set to true, and should be left out when not needed.
  • Update URI: Allows third-party plugins to avoid accidentally being overwritten with an update of a plugin of a similar name from the WordPress.org Plugin Directory. For more info read the related dev note.
/**
* Plugin Name: My Example Plugin
* Plugin URI: https://bloginbox.com
* Description: Add "Thanks for reading!" text under each post
* Version: 1.0.0
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Blog Inbox
* Author URI: https://bloginbox.com
* License: GPL v3 or later
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: my-example-plugin
* Domain Path: /languages
*/

3. Create plugin functionality

add_action( 'the_content', 'my_text_function' );function my_text_function ( $content ) {
return $content .= '<p>Thanks for reading!</p>';
}

4. Load plugin to WordPress

5. Activate your plugin

Conclusion

/**
* Plugin Name: My Example Plugin
* Plugin URI: https://bloginbox.com
* Description: Add text under each post
* Version: 1.0.0
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Blog Inbox
* Author URI: https://bloginbox.com
* License: GPL v3 or later
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: my-example-plugin
* Domain Path: /languages
*/
add_action( 'the_content', 'my_text_function' );function my_text_function ( $content ) {
return $content .= '<p>Thanks for reading!</p>';
}

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

7 Top Companies Using Serverless: How Codepen and Others Grow with AWS Serverless

Companies using Serverless

How to connect DevOps to your design system

The algorithm behind Google Search: an implementation with Python

Ledgerwise WAX Guild Update for the Month of September!

Prechat Form meets Freshchat.XYZ

Integration with Ballerina — I

SPIDERMAN | TOM HOLLAND | LIVE WALLPAPERS | @livtorresec

Working with database while using Multiprocessing

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Blog Inbox

Blog Inbox

More from Medium

How to Get WooCommerce Cart Items Info?

How to Get WooCommerce Cart Items Info?

WordPress Security(Part 01)

How To Duplicate Posts In WordPress

5 Issues You Must Know About Web Hosting