The best way to get better at riding is to ride. With that being said, to increase distance or speed, or both, the key is to not get complacent. If you push yourself a little bit each trip, you will do a little better each trip. There are apps available, such as TrainingPeaks, which provide you with a tool to create a training plan. Others, such as Strava, help to prevent complacency. You can see what others have done on a ride, and try to keep up or do better.
For distance training, the magic sauce really is putting in the miles. Pay attention to your cadence. Going at a higher RPM will allow you to ride longer, as your muscles won't fatigue as fast, but there is a cardio-vascular price to pay. Many say that around 90 rpm is ideal. I personally ride closer to 70, but I do start to feel it when I have a wicked climb later in a ride. Alternate your ride intensity. Take one day a week to crank out intervals, another day to ride at a low intensity and high cadence.
Think about your fuel. If you burn a few hundred calories in a ride, that energy has to have come from somewhere. Since it is ill advised to eat a big meal right before riding, think of fueling as something you do all day every day. Bring a snack with you on your ride, as well as sports drink in your bottles.
Finally, do not get discouraged. Approach each ride as its own event. The goal is to have a great ride. Sometimes the wind will be fighting you the whole way. sometimes you have a bad day. Think of all of the factors that go into a ride. Don't strictly compare times or speeds. A 7 mile ride with a 20 mph headwind is much different than a 10 mile ride with a 20 mph tailwind.
I will share a story with you. I started a new job about 2 years ago. I was riding my bike to work. It was a $100 super store bike. There was someone who I worked with that at one point in his life was a sponsored track racer. He saw me riding in one day, and we started talking. He asked me how far my ride was, and I told him about 2 miles each way. A few days later I overheard him making fun of me, saying I am not a real cyclist, my bike isn't a real bike. I decided that this will be my motivation. I started riding more, adding a loop around a block, or taking a detour on my way home. I kept riding, adding a little more at a time. He would continue to boast about his weekly 20 mile training rides. He would do his best to put me down over the distances I rode. Again, more motivation. A few weeks ago, we decided to race. Granted, he did not know that I had gone from 2 miles each way to over 250 miles of riding a week. We picked a 30 mile loop, he got on his $3500 full carbon racing rig while I hopped on my $800 alloy road bike, and set it up as a time trial. Needless to say, he has stopped talking at all about my riding.
The moral of the story is, keep riding, and enjoy the ride. If you don't enjoy what you are doing, you will stop doing it and never get better.