Created
June 6, 2021 16:05
-
-
Save edmunds22/55aced1ce29687a7c213333d53905fa9 to your computer and use it in GitHub Desktop.
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