Created
April 6, 2021 09:24
-
-
Save Gix075/33d4a076f14d37136419713444715629 to your computer and use it in GitHub Desktop.
Base WordPress shortcode example. This is a little shortcode boilerplate function.
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 | |
/** | |
* WordPress Shortcode Example | |
* Usage: [shortcode_example option="..."] | |
*/ | |
// Shortcode Handle Function | |
function shortcode_example_function( $atts ) { | |
$a = shortcode_atts( array( | |
'option' => "This is the default option value" // default options array | |
), $atts ); | |
// | |
if( !empty($a['option']) ) return "This is the shortcode output " . $a['option']; | |
} | |
// Add the shortcode | |
add_shortcode( 'shortcode_example', 'shortcode_example_function' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment