Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wordpress shortcode in 2 minutes
<?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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment