Sort posts by custom fields with empty values September 25, 2022 by Tarik Billa I found an other post on stackexchange that seems to answer your question: Order by optional meta key?