tehillim 24 was apparently written by dovid hamelech but as the gemera learns it was written by shlomo hamelech praising the dead, specifically dovid hamelech. who wrote it dovid or shlomo?
yoseph dov karr, passaic nj usa
Clearly, this Perek was written by David ha'Melech, as the verse specifically states.
The Gemara does not say that Shlomo ha'Melech wrote it, but rather that the verses that appear in it were said by Shlomo when he sought to bring the Aron ha'Kodesh into the Kodshei Kodashim. Hence, David wrote the verses, possibly prophesying about what his son would say in the future, and Shlomo used those words when he sought to bring the Aron ha'Kodesh to its place.
Y. SHAW