WP: Hello World Plugin

In this post, let’s look at how to create a simple “Hello World” plugin in WordPress. By “Hello World” I mean a “basic” plugin that does nothing special but you can upload and install it on your WordPress site.

Creating The Plugin

The first step is to create a plugin folder and plugin file with the plugin name. Let’s name our plugin hello-world-replace.

This means our folder structure would look like this: hello-world-replace > hello-world-replace.php.

Enter the following code in the main plugin file hello-world-replace.php

<?php 
/*
Plugin Name: Hello World
Plugin URI: https://csmumbai.com
Description: This plugin replaces all instances of "hello" with "Hello World"
Author: Omkar Bhagat
Version: 1.0
*/
 
function hello_world_replace( $text ) {
	return str_replace( 'hello', 'Hello World', $text );
}
 
add_filter('the_content', 'hello_world_replace');
 
?>

Save the file. Zip the folder. And the plugin is ready!

Testing The Plugin

To test the plugin, go to your site’s WP-Admin dashboard > Plugins > Add New and upload this zipped file.

Next create a post with hello text inside of it and publish it. Check the published version and you’ll find hello will be turned into Hello World.

That’s all in this post! 🙂

One thought on “WP: Hello World Plugin”

Leave a comment