Trench code
Trench codes (a form of cryptography) were codes used for secrecy by field armies in World War I. Messages by field telephone, radio and carrier pigeons could be intercepted, hence the need for tactical World War I cryptography. Originally, the most commonly used codes were simple substitution codes, but due to the relative vulnerability of the classical cipher, trench codes came into existence. (Important messages generally used alternative encryption techniques for greater security.) The use of these codes required the distribution of codebooks to military personnel, which proved to be a security liability since these books could be stolen by enemy forces.

By the middle of World War I the conflict had settled down into a static battle of attrition, with the two sides sitting in huge lines of fixed earthwork fortifications. With armies generally immobile, distributing codebooks and protecting them was easier than it would have been for armies on the move. However, armies were still in danger of trench-raiding parties who would sneak into enemy lines and try to snatch codebooks. When this happened, an alarm could be raised and a code quickly changed. Trench codes were changed on a regular basis in an attempt to prevent code breakers from deciphering messages.

French Army
The French began to develop trench codes in early 1916. They started out as telephone codes, implemented at the request of a general whose forces had suffered devastating artillery bombardments due to indiscretions in telephone conversations between his men. The original telephone code featured a small set of two-letter codewords that were spelled out in voice communications. This grew into a three-letter code scheme, which was then adopted for wireless, with early one-part code implementations evolving into more secure two-part code implementations. The British began to adopt trench codes as well.

German Army
The Germans started using trench codes in the spring of 1917, evolving into a book of 4,000 codewords that were changed twice a month, with different codebooks used on different sectors of the front. The French codebreakers were extremely competent at cracking ciphers but were somewhat inexperienced at cracking codes, which require a slightly different mindset. It took them time to get to the point where they were able to crack the German codes in a timely fashion.

U.S. troops
The Americans were relative newcomers to cryptography when they entered the war, but they did have their star players. One was Parker Hitt, b. 1878,  who before the war had been an Army Signal Corps instructor. He was one of the first to try to bring US Army cryptology into the 20th century, publishing an influential short work on the subject in 1915 called the Manual for the solution of military ciphers, Publication date 1916, available at https://archive.org/details/manualforsolutio00hittrich. He was assigned to France in an administrative role, but his advice was eagerly sought by colleagues working in operational cryptology. Another Signal Corps officer who would make his mark on cryptology was Joseph Mauborgne, who in 1914, as a first lieutenant, had been the first to publish a solution to the Playfair cipher.

When the Americans began moving up to the front in numbers in early 1918, they adopted trench codes and became very competent at their construction, with a Captain Howard R. Barnes eventually learning to produce them at a rate that surprised British colleagues. The Americans adopted a series of codes named after rivers, beginning with "Potomac". They learned to print the codebooks on paper that burned easily and degraded quickly after a few weeks, when the codes would presumably be obsolete, while using a font that was easy to read under trench conditions.

Communications discipline
American code makers were often frustrated by the inability or refusal of combat units to use the codes—or worse, to use them properly. A soldier engaged in combat doesn't always feel the need to do things "by the book" even when there are very good reasons to do so, and generals on the front line felt that they had other things to worry about. One codemaker suggested that the best way to address the problem was to publicly hang a few offenders, but he lacked the authority to do so.

The British and French were already familiar with such problems in "communications discipline". They hadn't completely solved the problems either, but they had at least managed to get it through the heads of most of their signalmen that if they didn't have time to properly encrypt a message, they shouldn't bother trying; send the message unencrypted, or "in the clear". A partially or badly encrypted message could undermine a cipher or code system, sometimes completely, which made an unencrypted message far preferable.

References

History of cryptography
Signals intelligence of World War I