I am traveling overland in Africa and volunteering for wildlife conservation programs. About 5 months into the trip, I plan to fly to the UK and France to visit my girlfriend's parents with her (She is from the UK). I am South African. Apparently you can't apply for a visa more than 3 months before the travel, but I will be in different parts of Africa by then, and the embassy also says you can only apply for a visa in another country if you are a resident there - which I will not be. So how do I get a visa?
You have a couple of options and you should probably look into both.
As mentioned in the comments, call the UK Embassy in South Africa, explain your situation and ask if they can issue a visa further ahead of your travels. Worse case they say No.
Talk to a visa service about your situation. You maybe able to send your passport via a reliable courier service (FedEx, DHL) to the visa service and have expedited visa processing done, then the passport returned to your location via the same courier method.
If you follow the second route, be sure to make a color copy of your passport's info pages (first two with your photo, details and signature), as well as a photocopy of your visa and entry stamp for the country you are in at that time.
If UK rules don't allow the use of a visa service in SA, then your only other choice is to fly back to SA for a short visit.