Listing all the currently available WordPress shortcodes

Who knows all the shortcodes that are currently available to your WordPress installation? I know I don’t. Well, inspired by a request from a WordPress VIP client to understand it better, here’s a quick and simple solution to list them out.

Add the following code to your theme’s function.php file and then add, to any page or post, the shortcode [shortcodes] to list out all of the available shortcodes. The code is ‘quick and dirty’ but does the job.

// 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' );
view raw functions.php hosted with ❤ by GitHub

One response

  1. this blog is very good

Talk to me!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: