Link had the Triforce of Courage in the Adult Timeline. When Zelda sent him back with the Ocarina of Time, he somehow exited through the Temple of Time. When Link returned, his testimony to Zelda of Ganondorf's betrayal lead to his execution before he had the time to actually do it. But the last time we saw Zelda in the Child Timeline was when she was on horseback leaving Hyrule Castle. Thus we can infer that Link went to a time before he even retrieved the Spiritual Stones, before he even met Zelda. This is further explained by Zelda's surprise by Link's entrance.
What does this mean? It means that if Link went before he even embarked on his quest, then the Door of Time was never opened, and Ganondorf never acquired the Triforce, which in turn did not split to its respectful owners. However, Link still has his Triforce piece in the Child Timeline, but how would this be if the Triforce appears in Wind Waker? We can infer that when Link travels between time, he passes through the Chamber of Sages. So when Link returned to his childhood for good, his Triforce was left behind; and his appearance in the Chamber of Sages in the Child Timeline ignited the Triforce to be separated, which explains how the Triforce is shown in both Wind Waker and Twilight Princess. Henceforth, the Triforce of Courage is given to Link, the Triforce of Wisdom to Zelda once again, and in the middle of his execution, Ganondorf as well.