{"id":382697,"date":"2024-11-27T09:09:14","date_gmt":"2024-11-27T16:09:14","guid":{"rendered":"https:\/\/css-tricks.com\/?p=382697"},"modified":"2024-11-27T09:09:20","modified_gmt":"2024-11-27T16:09:20","slug":"wordpress-multi-multisite-a-case-study","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/wordpress-multi-multisite-a-case-study\/","title":{"rendered":"WordPress Multi-Multisite: A Case Study"},"content":{"rendered":"\n

The mission:<\/strong> Provide a dashboard within the WordPress admin area for browsing Google Analytics data for all your blogs.<\/p>\n\n\n\n

The catch?<\/strong> You\u2019ve got about 900 live blogs, spread across about 25 WordPress multisite instances. Some instances have just one blog, others have as many as 250. In other words, what you need is to compress a data set that normally takes a very long time to compile into a single user-friendly screen.<\/p>\n\n\n\n\n\n\n\n

The implementation details are entirely up to you, but the final result should look like this Figma comp:<\/p>\n\n\n\n

\"\"
Design courtesy of the incomparable Brian Biddle<\/a>.<\/figcaption><\/figure>\n\n\n\n

I want to walk you through my approach and some of the interesting challenges I faced coming up with it, as well as the occasional nitty-gritty detail in between. I\u2019ll cover topics like the WordPress REST API, choosing between a JavaScript or PHP approach, rate\/time limits in production web environments, security, custom database design \u2014 and even a touch of AI. But first, a little orientation.<\/p>\n\n\n

Let\u2019s define some terms<\/h3>\n\n\n

We\u2019re about to cover a lot of ground, so it\u2019s worth spending a couple of moments reviewing some key terms we\u2019ll be using throughout this post.<\/p>\n\n\n

What is WordPress multisite?<\/h4>\n\n\n

WordPress Multisite<\/a> is a feature of WordPress core \u2014 no plugins required \u2014 whereby you can run multiple blogs (or websites, or stores, or what have you) from a single WordPress installation. All the blogs share the same WordPress core files, wp-content folder, and MySQL database. However, each blog gets its own folder within wp-content\/uploads for its uploaded media, and its own set of database tables for its posts, categories, options, etc. Users can be members of some or all blogs within the multisite installation.<\/p>\n\n\n

What is WordPress multi-<\/em>multisite?<\/h4>\n\n\n

It\u2019s just a nickname for managing multiple instances of WordPress multisite. It can get messy to have different customers share one multisite instance, so I prefer to break it up so that each customer has their own multisite, but they can have many blogs within their multisite.<\/p>\n\n\n

So that\u2019s different from a \u201cNetwork of Networks\u201d?<\/h4>\n\n\n

It\u2019s apparently possible to run multiple instances of WordPress multisite against the same WordPress core installation. I\u2019ve never looked into this, but I recall hearing about it over the years. I\u2019ve heard the term \u201cNetwork of Networks\u201d and I like it, but that is not the scenario I\u2019m covering in this article.<\/p>\n\n\n

Why do you keep saying \u201cblogs\u201d? Do people still blog?<\/h4>\n\n\n

You betcha! And people read them, too. You\u2019re reading one right now. Hence, the need for a robust analytics solution. But this article could just as easily be about any sort of WordPress site. I happen to be dealing with blogs, and the word \u201cblog\u201d is a concise way to express \u201ca subsite within a WordPress multisite instance\u201d.<\/p>\n\n\n\n

One more thing: In this article, I\u2019ll use the term dashboard site<\/strong> to refer to the site from which I observe the compiled analytics data. I\u2019ll use the term client sites<\/strong> to refer to the 25 multisites I pull data from.<\/p>\n\n\n

My implementation<\/h3>\n\n\n

My strategy was to write one WordPress plugin that is installed on all 25 client sites, as well as on the dashboard site. The plugin serves two purposes:<\/p>\n\n\n\n