When a lyricist writes a lyric inspired by a specific melody, then discards that melody and keeps the lyric, we say that the lyric was written to a ghost melody.
Lyricists do this sometimes when inspired by the melody of a copyrighted song. To avoid infringement, the original melody is discarded and a new one is composed.
Writing lyrics for a ghost melody has several advantages: 1. it allows a non-musical lyricist to write with a melody in mind; 2. the entire structure of the original song can also be borrowed; 3. once it is divorced from its original melody, few people would notice any similarity between the finished product and the song that originally inspired it.
A songwriter who writes lyrics and composes may find it difficult to shake off the ghost melody enough to devise a new one. In this case, it may help to set aside the lyric for a while or to bring in a collaborator–without telling them the tune that the new lyric was based on.
Another potential pitfall of writing to a ghost melody is the tendency to also borrow lyric phrases. Lyricists should always compare the lyric of the ghost melody with their own finished lyric to make sure they haven’t subconsciously borrowed too freely from the original.