Skip to content

Instantly share code, notes, and snippets.

@dartiss
Last active October 23, 2018 11:32
Show Gist options
  • Save dartiss/256874361677f418d14086fa81ac8b33 to your computer and use it in GitHub Desktop.
Save dartiss/256874361677f418d14086fa81ac8b33 to your computer and use it in GitHub Desktop.
List WordPress shortcodes
<?php
// Shortcodes to list all available shortcodes
function list_shortcodes() {
// Grab the global array of shortcodes
global $shortcode_tags;
// Sort the shortcodes into alphabetical order
$shortcodes = $shortcode_tags;
ksort( $shortcodes );
// Loop through the array and output all the shortcodes
$output = '<p>Currently available shortcodes are as follows:</p><ul>';
foreach( $shortcodes as $code => $function ) { $output .= '<li>' . $code . '</li>'; }
$output .= '</ul>';
// Send the resulting output back for display
return $output;
}
add_shortcode( 'shortcodes', 'list_shortcodes' );
?>
@dartiss
Copy link
Author

dartiss commented Nov 14, 2017

Add this code to functions.php and then use the shortcode [shortcodes] on a post or page to list all of the shortcodes currently available.

https://artiss.blog/2017/07/listing-all-the-currently-available-wordpress-shortcodes/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment