Ionic compounds only conduct electricity only when molten or in solution.

When solid the ions are not free to move.

 

When molten or in solution the ions are free to move.