Grocery list paper on a ground

Meet The Plugin That Lists All Your Multisite’s Sites: Multisite Site List

Have you ever found yourself in this common situation?

“I’ve got this lovely WordPress Multisite, but I’d like to list every site on it in a post or page!”

Of course you have–we’ve all been there.

Well, let me introduce you to my newest plugin: site-list

Installing the Plugin

Installing it is a breeze, and using it is as easy as pie—assuming you find pie easy. Just clone the git repository, grab the code, upload it to your WordPress site, and enable it. Don’t forget to constantly check back in the repository for updates that will probably never come because I didn’t upload this to the WordPress.org Plugin Repository.

Example Output

This plugin does one thing: It adds a new block called “Multisite Site List” that lists the site in a multisite in an unordered list, like this:

<ul class="ms-sites-list">
	<li>
		<a href="https://example.com/">My Website</a>
		<p>The Super Awesome Site Tagline</p>
	</li>
	<li>
		<a href="https://example.com/better-site">My Even Better Website</a>
		<p>The Better Site Tagline</p>
	</li>
	<li>
		<a href="https://example.com/garbage-site">My Blarg</a>
		<p>Why are you even reading this?</p>
	</li>
</ul>Code language: HTML, XML (xml)

Customizing the Output

“But Derrick, what if I want to hide a site, or change something?”

Why would you? This is perfect as-is. *sigh* Oh, you want to be the captain of your ship? Fine, here’s a filter for you:

/**
 * Filters the list of sites retrieved by the `get_sites()` function.
 *
 * This filter allows developers to modify the list of sites before
 * they are processed and rendered in the `ms_sites_list_block_render()` function.
 * It can be useful for modifying, adding, or removing sites based on custom criteria
 * or to inject additional information into the sites' data.
 *
 * @param array $sites An array of `WP_Site` objects representing each site in the WordPress multisite network.
 */
$sites = apply_filters( 'site_list_get_sites', get_sites() );Code language: PHP (php)

Happy now?

So yeah, this is a thing. Do what you want with it, and enjoy.

Other Posts Not Worth Reading

Hey, You!

Like this kind of garbage? Subscribe for more! I post like once a month or so, unless I found something interesting to write about.