Skip to content

Instantly share code, notes, and snippets.

@EricBusch
Last active April 12, 2017 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EricBusch/8090711804382333e66e to your computer and use it in GitHub Desktop.
Save EricBusch/8090711804382333e66e to your computer and use it in GitHub Desktop.
Display widget ID for each widget on the Widgets admin page. [wordpress]
<?php
/**
* Display widget ID on Widgets page.
*
* Use this to see the IDs of all of your widgets here:
* WordPress Admin Area > Appearance > Widgets
*
* To disable, simply comment out the add_filter() function.
*
* @param array $params Information about this widget.
* @return array The updated $params array.
*/
add_filter( 'dynamic_sidebar_params', 'mycode_dynamic_sidebar_params' );
function mycode_dynamic_sidebar_params( $params ) {
$params[0]['widget_name'] = '(' . $params[0]['widget_id'] . ') ' . $params[0]['widget_name'];
return $params;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment