A recently demolished church in the Caerphilly county borough will be replaced by 16 flats.