MicroSD card keeps disappearing from storage

I’ve been struggling with this problem, too described here:

My SD card “disappears” and is forgotten and not recognised when (a) I reboot my phone OR (b) when I shut it down and turn it back on OR (3) when I plug my phone via USB into my computer for charging. In Storage settings, I can see the button to mount my SD card, but pressing it doesn’t do anything! I have to open the back case (while the phone is on), remove the SD card then put it back in a few times before it is recognised and mounted. I suspect this is a software issue, because when the SD card is physically removed, the mount SD card button in Storage settings is greyed out. However, if the SD card is physically plugged in, the mount SD card button is not greyed out, it just doesn’t do anything.

I have since tried switching to MTP mode, trying different SD cards, both to no avail. The problem remains. Anyone has suggestions?