I generally listen to the song and try to figure how to fake it so it sounds close (a bad way). My neighbor tends to watch guitar player teachers on YouTube and study videos etc. He does a good job in picking up some of the theory of playing and how to always find the appropriate notes to through into a solo. I had always just listened closely, played around at what I could to find parts that fit in and complemented what was going on.
A looper can be handy in putting down the basic chords to learn to solo over or to add a counterpoint or bass track to.
I’ve been playing (poorly) for a lot of years, but never really bothered to study theory or any of that. Now I’m getting into actually learning how, what where and when to play.