Wordpress shortcode in 2 minutes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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