I read a comment recently which stated that the First World War greatly affected attitudes towards sexuality in both women and men. I always thought that sexuality was repressed during the war, especially with homosexuality in the army as it would've gone against the masculine idea soldier that people saw at the time
The 'masculine ideal soldier' you've mentioned played a large part in the expression of emotion, gender and sexuality in the twentieth century. WWI has been seen as something of a turning point for expression of masculinity, as noted by Michael Roper in The Secret Battle: Emotional Survival in the Great War and Jessica Meyer in Men of War: Masculinity and the First World War in Britain. This is due to shell shock and the change in many men's view of themselves because of their 'hysteria', seen as a feminine disorder. Here is a literature review of some of the leading monographs on the subject of WWI and masculinity. Hopefully this will provide some context for your question.
The subject of sexuality, especially male sexuality, in the First World War, is a complex one that has some rather extensive historiography. I will try to be brief and helpful at the same time. The comment you saw, to some degree, has some truth to it. That is to say that sexuality during the war era was repressed to a degree. This repression was arguably a result of a societal fear for of crossing gender roles. That is: that to be a man was to be the opposite of a women, or as non-feminine as possible. For example, men who were passive (sexually, personally, or in whatever industry they pursued) “leaves on branded a 'fag' or a 'sissy', a homosexual or effeminate man,”1. There was certainly plenty of homosexual activity between soldiers during the first world war as well, and it is evident in the large amount of wartime personal literature, including letters, and poems. For example:
I, that have held strong hands which plater,
Borne the full weight of limbs that falter,
Bound live flesh on the surgeons alter,
What need have I of woman's hand?
I, that have felt the dead's embrace;
I, whose arms were his resting place;
I, that have kissed a dead man's face;
Ah, but how should you understanding
Now I can only turn away.2
Lastly, it was not only homosexuality that was repressed, homosexuality being anathema to the societal image of the "manly man" that Christian moral imperatives and societal gender rules imposed, but also non- monogamous sexual practices, especially prostitution. Men were expected to be "morally clean"3 and avoid prostitutes due to strong Christian nationalist cultural pressures: “Front newspapers published articles by military doctors on the dangers of venereal disease that emphasized sexual control as a heroic ideal, necessary not only for the health of their families, but also the survival of the nation”4. Militaries had their own doctrines about soldier's access to prostitution (I'm sure a military historian could describe the lengthy, global relationship between soldier and prostitute): “Military authorities generally saw soldiers’ sexual activity and search for relief as a natural instinct that could not be negated, but had to be managed.”5 and some militaries (as described in the quote, namely the German army) had the practice of 'rationing' sex to their soldiers, inspecting prostitutes for general disease and otherwise institutionalizing prostitution (to some degree) into their military logistics.
Edited several times for formatting.
I wouldn't say that sexuality was repressed in WWI; on the Western Front for example, extensive use was made of regulated prostitution, with brothels set up behind the lines for the soldiers.
As to homosexuality, Richard Holmes' book on the British soldier on the Western Front, Tommy, makes mention of some homosexual/pseudo-homosexual relationships in the ranks. In some cases it would seem that soldiers simply turned a 'blind eye' to these liaisons.
Related question: What were the effects (if any) of the post-WWI "shortage" of men on sexuality, marriage, or family norms? Did it become more permissible for a woman to pursue a guy romantically, since she had so much more competition?