We have a lot of WordPress shortcodes on this website - [shortcodes count="1"] of them and counting. The number of shortcodes listed above is a live count and will update when a new shortcode is published to the website... and this feature forms part (if not the focus) of the function we've provided below. The other component of the shortcode function will list all your shortcode functions in a list.
The Result
The usage that motivated the code was a means of counting the number of our registered shortcodes. So, [shortcodes count="1"]
will output [shortcodes count="1"]. You might optionally list all shortcodes with [shortcodes]
.
If you run a publishing site and need to provide a resource on shortcode usage, linking to an author-only page with the same slug name detailing shortcode usage (and attributes) might be an easy means of keeping your team educated.
[shortcodes]
The Shortcode Function
Copy and paste the WordPress function into your theme's functions.php
file or, if you sensibly have one installed, your custom functions plugin.
If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.
Shortcode Attributes
count
count="1"
.cache
cache
is the length of time we'll cache the result.