Copy the code below into wp-content/plugins/my_shortcode/my_shortcode.php
<?php
/**
* Plugin Name: Sample Plugin
* Plugin URI: https://wpedmunds.uk
* Description: A demo plugin
* Version: 1.0
* Author: WP Edmunds
* Author URI: https://wpedmunds.uk
*/
function my_shortcode($atts = []) {
$html = '
<h1>Hello World!</h1>
';
return $html;
}
function my_shortcode_scripts() {
wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'my_shortcode_scripts');
add_shortcode( 'MY_SHORT_CODE', 'my_shortcode' );
Download sample file