Wei Wuxian in his first lifetime thought he only liked girls (despite having the huge-est crush on Lan Wangji since the Cloud Recesses arc). Him thinking "I like girls!! Hence I can't be into guys!!" and running with it to completely disregard his evident attraction to men, because its a can of worms that his brain is sub-consciously telling him not to open. And so he doesn't.
Even with all the obvious pining, you'd think it would be evident but it isn't because cognitive dissonance is strange and the amount of mental gymnastics that take place in our brains to reinforce the facts we deem as the truth can be astounding.
After he is resurrected in Mo Xuanyu's body, he starts using mxy's reputation as a gay man to his advantage in various ways. But then again we see him in Qinghe, where nobody knows mxy or the fact that he's gay, buying rouge from a salesman just to piss him off while keeping up the "gay act" even when there was no need. He's always pretending to be gay to either disgust people to keep them away from him or to get out of tricky situations or to mock people for his entertainment.
Wwx is slowly settling in with the idea of being attracted to men even if he still thinks its an act.
By the time he's in the Carp Tower, he has already flirtatiously smiled at a waitress before he remembers that mxy is supposed to be exclusively attracted to men.
And this is the moment that drives me crazy because according to him he had been "in character" because he was "bothering" Lwj in "gay" ways. But in reality he stopped pretending to be Mxy and started being himself; flirting with Lwj and any woman that he deemed pretty. But the difference is that now he recognises his own actions as queer, unlike before. Even if he thinks that he's joking.
Then he makes a great show and pomp infront of Jin Ling about how he's in love with Lwj now and feels ashamed when he realises that Lwj had heard it all because now he's starting to become some what aware of his own feelings and the connotations of the jokes he makes. From Carp Tower onwards Wwx starts becoming more aware of his own feelings and the way Lwj treats him until he finally reaches his conclusion regarding his feelings for Lwj.
Yes, Wwx was joking when he wondered that if it was possible that attraction towards men could be passed on via the sacrifice but him pretending to be Mxy and mucking around with the idea of being attracted to men was what paved the way for him to come to terms with his own sexuality and feelings.