Last active
October 23, 2018 11:32
-
-
Save dartiss/256874361677f418d14086fa81ac8b33 to your computer and use it in GitHub Desktop.
List WordPress shortcodes
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 | |
// 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' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/