Get Aaron Shearer's "Basic Elements of Music Theory for the Guitar"...it's the Bible.
Nearly every song you will ever play follows some form of the music theory presented in this book...and it will amaze you to see the theory that is going on in some songs, especially the more complicated ones by innovative composers like Villa-Lobos or Rodgrigo.
I don't always take the time to do that, but when I do, it's rewarding.
People who've been to music school and are degreed know how to take any melody and write a guitar solo based on it. I wish I could do that. My old teacher has written a book about this which will be published next April....he's promised me an autographed copy...I hope I get it!