No electronics work in my 97 ford ranger?

When I bought it nothing worked like power windows, power locks, horn, guages, headlights, inside lights, but the radio and climate controls work. What could be wrong. Is it all linked to one thing? The headlight switch is screwed up can that effect all these?

A bad ground will wreak all sorts of havoc to a vehicles electrical systems. I would start by making sure the ground has a very good connection.
Also, check all the fuses.

The headlight switch probably isn't the culprit, but it could be if it's shorting out the ground.

Check Fuses.

Check any ground wires. If you recently changed battery, might have blown a fusible link or let some tiny ground wire off.

Headlamps could have 2 issues; , the bad switch and a fuse that it caused to blow. Replace switch, first.

Have you even looked at the main fuses in the engine bay? It could also be a fusible link that is fried. The headlight switch could have blown some fuses if the power was shorted out.