Great question — answering as the UphillTech team:
Yes, your suggestion of mounting a piece of wood to the wall is probably the best option. I did this in my house, and I've seen other people do it too. However, it may not be true that the stud is where the railing is mounted. In my house, the closest stud to the corner is closer to 5" away from the corner. (See my version of this question .) You can use a stud finder to verify how far away there is actually a stud, and then size your wood accordingly. You will also want to use drywall anchors closer to the gate to prevent torquing on the piece of wood if someone pushes against the gate. The anchors won't be the main thing holding the gate in place, but they will provide some stability to...
Full answer by Moshe Katz: https://diy.stackexchange.com/a/322930 (CC BY-SA 4.0).
Need it done for your business? UphillTech.