Gas oven fails to heat up.

Hi. I have a Whirlpool gas oven. The oven sometimes works but most of the time the gas will not stay on in the oven. When I set a bake temp and press start. I can see the ignition spark and gas comes on but quickly it will shut off. About a minute later the oven will ignite and again gas turns off so after. I initially replaced temp sensor. Oven still did not work properly. I replaced with new oven ignition but stove only worked two times before it started shutting the gas off again. Please help.