Absolutely. Creating a basic WordPress plugin is actually very easy. Here is the simplest beginner example.
Step 1: Create a plugin folder
Go to your WordPress installation:
wp-content/plugins/
Create a new folder called:
my-first-plugin
Step 2: Create a PHP file
Inside that folder, create:
my-first-plugin.php
Your structure should look like:
wp-content/
└── plugins/
└── my-first-plugin/
└── my-first-plugin.php
Step 3: Add the plugin code
Open my-first-plugin.php and add:
<?php
/**
* Plugin Name: My First Plugin
* Description: My first simple WordPress plugin.
* Version: 1.0
* Author: Your Name
*/
// Display a message in the footer
function my_first_plugin_message() {
echo '<p style="text-align:center;">Hello! My first WordPress plugin is working.</p>';
}
add_action('wp_footer', 'my_first_plugin_message');
Step 4: Activate the plugin
Go to your WordPress dashboard:
Plugins → Installed Plugins
You should see My First Plugin.
Click Activate.
Step 5: Check your website
Visit your website and scroll to the bottom.
You should see:
Hello! My first WordPress plugin is working.
🎉 Congratulations! You created your first WordPress plugin.
How it works
The important parts are:
function my_first_plugin_message() {
This creates a PHP function.
add_action('wp_footer', 'my_first_plugin_message');
This tells WordPress:
"Run my function when WordPress reaches the footer."
That's the basic idea behind many WordPress plugins: write a function → connect it to WordPress with a hook → WordPress runs it at the appropriate time.
0 comments:
Post a Comment
Thanks