I think you may have answered this one yourself. There are some cases where you need to eat little and often to stop this happening. This used to happen the same with me, but now I am down to eating 3 times a day opposed to my usual 6 due to a discussion with my GP and how many times my bowels were opening. My bowels haven't got any better, but it has managed to stop the pain when my stomach is expecting food every 3-4 hours, so there is a positive in my story.
Of course though, everybody is different. Maybe just try eating little and often.