Easy Hello World WP Plugin

Easy Hello World WP Plugin
How you can easily make your own simple WordPress Plugin

Creating a basic plugin is super easy. You don’t even need to know code; you can ask AI to write it for you. But it helps if you know PHP, JavaScript, HTML, are familiar with the WordPress Dashboard, and know how to troubleshoot.

This plugin will just replace everywhere it finds [hello_world] in square brackets with Hello World in a blue font. What’s the point? Well, it’s only to show you how easy it can be to create and install a WordPress plugin. I’m planning to post more useful tutorials in the future.

NOTE: You will not be able to install plugins on the free WordPress plans.

Example

“Hello World” Should appear below in a blue font.

Hello World

Step 1

Create a file called hello-world-plugin.php and copy the text below into it

<?php
/**
 * Plugin Name: Hello World Shortcode
 * Description: A simple shortcode that displays "Hello World"
 * Version: 1.0
 * Author: Les Ey
 * Author URI: https://les-ey.online 
 */

// Exit if accessed directly. This ensures the file is only loaded within the WordPress environment.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * hello_world_shortcode() - Shortcode Handler
 *
 * Defines the content that will be output when the shortcode 
 * [hello_world] is used.
 * @return string The HTML content to display.
 */
function hello_world_shortcode() {
    return '<span class="hello-world">Hello World</span>';
}
add_shortcode('hello_world', 'hello_world_shortcode');

/**
 * hello_world_styles() - Frontend Styles
 *
 * Embeds a <style> block directly into the HTML <head> for the
 * shortcode's output.
 */
function hello_world_styles() {
    echo '<style>.hello-world { font-weight: bold; color: #0073aa; }</style>';
}
add_action('wp_head', 'hello_world_styles');
Step 2

Create a zip file of hello-world-plugin.php as hello-world-plugin.zip

In windows you can right click and select send to then Compressed (zipped) Folder

Step 3

Log into WordPress Dashboard and select Plugins

Step 4

Click the Add Plugin button, then click the Upload Plugin and browse to and select the zip file you created. Then click Install Now

Note: Your theme dashboard/menus may look different, but the steps should be the same.

Step 5

Click Activate Plugin.

STEP 6

Create a new post and type [hello_world].

Step 7

Publish or preview your post to check that it works.

That’s it. You’ve just created your own plugin. Next time I will show how you how to easily change the font color.

Got Questions?

Views: 122