Many people are telling you that discipline is the solution. They're not necessarily wrong, but the most disciplined person in the world cannot squeeze blood from a stone. Sometimes you're mentally fatigued, discouraged, and the task at hand seems overwhelming.
For me, progress is the solution to burnout. Stop whatever hard problem you're working on for a bit and work on something simple -- layout tweaks, small bug fixes, code cleanup, automated tests. This usually gives me the extra boost of dopamine I need to handle the larger task at hand.
Your mileage may vary of course but it's something that has worked wonders for me.