Count instances of a given widget that are active

110 Views Asked by At

I'm looking for a way to count active instances of a given widget across a WordPress Network. For instance, I have Widget A. I need to count how many times Widget A exists in any sidebar on any site within the network. Obviously WP-CLI is probably the way to go, but I'm struggling with identifying active widgets.

1

There are 1 best solutions below

0
On

The answer is WP-CLI. Iterate through all sidebars then iterate through all widgets in those sidebars.

Sample code:

https://gist.github.com/mrpritchett/e9a48b959e5d78d2d8174d97361c1c4b