• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

I Like Kill Nerds

The blog of Australian Front End / Aurelia Javascript Developer & brewing aficionado Dwayne Charrington // Aurelia.io Core Team member.

  • Home
  • Aurelia 2
  • Aurelia 1
  • About
  • Aurelia 2 Consulting/Freelance Work

WordPress Multisite Domain Issues? You Might Be Forgetting to Call restore_current_blog

Wordpress · October 18, 2021

Recently, I created a WordPress Multisite installation on Amazon AWS Lightsail. I had this bizarre issue where my child sites were working, but whenever I would try creating posts or pages, the new button would take me to the root domain. Chalk this one up to stupidity (on my part).

It was a perplexing issue because it was acting like I was in the admin panel for the root domain, not the child site. It was even showing my post counts for the root domain (but not posts). Going to the permalinks screen was showing the root domina, everything was a disaster.

I could not work out what was going on. I debugged my .htaccess, and to an extent, my wp-config.php file. Nothing seemed to fix the issue. The one thing I could see was disabling my theme fixed the problem.

I realise this is quite specific, but I was calling switch_to_blog(1) inside a function call. The rookie error I made was forgetting to call restore_current_blog at the end of the function. This straightforward mistake caused an issue so significant. I pulled apart half of my site, trying to fix it.

So, the moral of the story is, if you’re having Multisite domain issues and you’ve checked your .htaccess and wp-config.php are not the culprit, this might be an avenue to explore.

Dwayne

Leave a Reply Cancel reply

0 Comments
Inline Feedbacks
View all comments

Primary Sidebar

Popular

  • How To Get The Hash of A File In Node.js
  • Testing Event Listeners In Jest (Without Using A Library)
  • Which Neural DSP Archetype Plugins Should You Buy?
  • Smoke Detector Randomly Goes Off Early Hours of The Morning
  • How to Fast Launch Microsoft Flight Simulator 2020 (decrease game loading time)
  • How to Copy Files Using the Copy Webpack Plugin (without copying the entire folder structure)
  • A review of the Neural DSP Quad Cortex: is this the future of amp-modelling?
  • NBN Box Installed Inside of Garage, Where Do You Put The Modem?
  • How To Mock uuid In Jest
  • Convert A Firebase Database Snapshot/Collection To An Array In Javascript

Recent Comments

  • Thebe on How to Remove the My Sites Menu From the WordPress Admin Bar
  • Maccas worker jn the 2000s on Dear McDonald’s: bring back the Warm Cookie Sundae, you cowards
  • Anamika Singh on Testing Event Listeners In Jest (Without Using A Library)
  • Stefan on A List of WordPress Gutenberg Core Blocks
  • pandammonium on A List of WordPress Gutenberg Core Blocks

Copyright © 2022 · Dwayne Charrington · Log in

wpDiscuz