The real and only answer, is to have a mini tournament in the winter before to decide where the remaining places go to. In the qualifying season just gone, that could have looked something like this:
Group A - Bosnia and Herz (UEFA), Iraq (AFC), Guatemala (CONCACAF), Zambia (AFC)
Group B - Greece (UEFA), UAE (AFC), Canada (CONCACAF), Ivory Coast (AFC)
Group C - Netherlands (UEFA), Ecuador (CONMEBOL), Haiti (CAF), New Zealand (OFC)
Group D - Italy (UEFA), China (AFC), Paraguay (CONMEBOL), Uganda (CAF)
Group E - Northern Ireland (UEFA), Thailand (AFC), Trinidad and Tobago (CONCACAF), DR Congo (CAF)
Group F - Slovakia (UEFA), Qatar (AFC), Honduras (CONCACAF), Burkina Faso (CAF)
Group G - Ireland (UEFA), Uzbekistan (AFC), Ghana (CONCACAF), Solomon Islands (OFC)
Group H - Scotland (UEFA), Syria (AFC), United States (CONCACAF), Chile (CONMEBOL)
Hold it over an 9 day period in January at the World Cup hosts (Weekend, Midweek, Weekend). Top 2 teams in each group go to the world cup.
Those are based on the 2018 world cup qualifying, but there are loads of teams who have done okay at previous word cups who haven't even qualified for that.
Anyone who get's through that has earned their place.
I think this is kind-of what will happen in future anyway, but right now there is a 6 team qualfying tournament in 2025... not a 32 team one!
https://en.wikipedia.org/wiki/2026_FIFA_World_Cup#Playoff_tournament