Try looking at you wp-config.php file. Any sort of stray character can set it off and blank your pages. The other night i had a stray “/” and it took me a while to figure out why my pages weren’t showing up.
I have posted the fix Here
PS i want this all to be done through a plugin that im developing. Is this possible? If so what functions should i be looking at.