Trench latrines were the main answer
Soldiers at the front mostly used latrines dug into the ground. In the trench system, these were often separate pits or short trenches dug at the edge of the living area. Wooden planks or simple seats were sometimes fitted across them. When a latrine filled up, it was usually covered over and a new one dug. Commanders tried to place latrines away from living areas and water supplies, but the ground and the fighting often made this difficult.
Buckets, pits, and arrangements behind the lines
Where digging was impossible, such as on waterlogged ground or during heavy shelling, men might use buckets or other containers. These had to be emptied and cleaned, which added to the workload of the unit.
Behind the lines, camps and billets had more organized latrines, with trenches or pits laid out in rows and screened where possible. The arrangements were still basic by modern standards.
Lime and fly control
Quicklime or chloride of lime was often thrown into latrines to reduce smell and help control germs. Flies were a major problem, since they could carry germs from latrines to food. Army sanitary rules tried to keep latrines covered, placed away from kitchens, and used by the men, but enforcement was uneven.
Why sanitation mattered
Poor sanitation contributed to diseases such as dysentery and typhoid. Men who lived in trenches for long periods were exposed to contaminated ground and water. Improving latrines was one of many steps military medical staff pushed for, though it was hard to achieve under fire.
Latrine duty and the worst job question
Latrine duty is often named when people ask what was the worst job in ww1. Digging, filling, and cleaning latrines was hard, unpleasant work, and it was rarely popular with the men assigned to it.