Emergence of charge order in a staggered loop-current phase of cuprate high-temperature superconductors