Skip to main content

Sort objects by ACF field

If you want your database to be sorted by ACF field, add the code below to MapSVG > Menu > JavaScript > Map > afterLoadObjects (replacing the existing code).

Change fieldName string to your own ACF field name.

function(event){
const { map } = event
var fieldName = 'fieldName'
map.database.getLoaded().sort((objA, objB) => objA.post.acf['fieldName'] > objB.post.acf['fieldName'] ? 1 : -1)
}