How to Get the Active Shortcodes List in WordPress

Shortcodes in WordPress are something that everyone loves to use. but sometimes, you don’t actually remember how many active shortcodes are there on your website.

In this article, I will show you the easiest way to get the list of active shortcodes on your website, and display them as a list in the WordPress Pages/Posts and Backend (WP Admin) area.

Sounds Interesting..?. Let’s jump into this.

Get WordPress Shortcodes List

To get the list of shortcodes, first, we will create a custom shortcode to get the list of active shortcodes and then will use that shortcode to display the shortcode list.

Open your theme’s functions.php file and paste the below code at the bottom and save it.

//  Functions to display a list of all the shortcodes
function diwp_get_list_of_shortcodes(){

	// Get the array of all the shortcodes
	global $shortcode_tags;
	
	$shortcodes = $shortcode_tags;
	
	// sort the shortcodes with alphabetical order
	ksort($shortcodes);
	
	$shortcode_output = "<ul>";
	
	foreach ($shortcodes as $shortcode => $value) {
		$shortcode_output = $shortcode_output.'<li>['.$shortcode.']</li>';
	}
	
	$shortcode_output = $shortcode_output. "</ul>";
	
	return $shortcode_output;

}
add_shortcode('get-shortcode-list', 'diwp_get_list_of_shortcodes');

The above code will create a custom shortcode called [get-shortcode-list] in your theme.

Now you can use this shortcode [get-shortcode-list] within your page, post, widget, theme, or with PHP, to display the list of all the active shortcodes in your WordPress website.

I have written an article on using shortcodes within the theme, where I have outlined using shortcodes inside the theme, template, widget, PHP files.

And you will see a list of all the active shortcodes on your WordPress website like in the below image.

Note: Your list of shortcodes can be different from the image shown below

find-all-active-shortcodes-in-wordpress

Get WordPress Shortcodes List in WordPress Admin Area

If you want to get the list of all your shortcodes inside in WordPress admin area, then you can use the code snippets given below:

This code will add an option under settings called Active shortcodes, and there you can see the list of all the active shortcodes.

Copy the code given below and add it to your theme’s functions.php file.

// Create an options page to display the list of shortcodes in WordPress

function diwp_display_shortcodes_admin_page() {

  add_options_page('All Active Shortcodes', 'Active Shortcodes', 'manage_options', 'active-shortcodes', 'diwp_display_list_of_shortcodes');

}

add_action('admin_menu', 'diwp_display_shortcodes_admin_page'); 


// function to display the list of active shortcodes in WordPress

function diwp_display_list_of_shortcodes(){
	
	global $shortcode_tags;
	
	$shortcodes = $shortcode_tags;
	
	// sort the shortcodes with alphabetical order
	ksort($shortcodes);
	
	echo "<h2>List of All Active Shortcodes in Your Website.</h2>";

	echo "<ol>";
	
	foreach ($shortcodes as $shortcode => $value) {
		echo '<li>['.$shortcode.']</li>';
	}
	
	echo "</ol>";
	
}

Now go back to your WordPress dashboard and click on Settings, and you will see an option Active Shortcodes.

find-all-active-shortcodes-in-wordpress-2

Click on Active Shortcodes and this will show you the complete list of all the active shortcodes on your website.

find-all-active-shortcodes-in-wordpress-3

That’s it. You’re done.

I hope this article helps you to learn how to get a list of all the active shortcodes on your WordPress website in page or post and the WordPress admin area.

4 thoughts on “How to Get the Active Shortcodes List in WordPress”

  1. Hi, I cannot tell how long ago you posted this, but nonetheless, I’d like to ask if the procedures above will include shortcodes that the site has but are NOT being used (inactive) in addition to the active ones that are being used?

    Thanks, MK

    1. Bhuvnesh Shrivastava

      Hi MK,

      The above code will get you list of all the shortcodes site has, if they are registered as shortcode with WordPress. And if your site has shortcodes those are not registered, then WordPress will not consider them as shortcodes and they act like just a piece of text.

      Hope it’s clear to you.

  2. Wanted this a long time. My list has 98 shortcuts on it!
    But WHERE are they all being used? Can you do that?

    1. Bhuvnesh Shrivastava

      Hi Russ,

      To get the page, post or location where the shortcode getting used is something that I have not tried. But I will try to find their respective location if possible and get back to you. Keep Visiting Dive In WP.

      Thanks

Comments are closed.