Get custom field data for many pages more efficiently

I’m using the WordPress plugin Custom Field Suite

I have probably 80 pages (different stores) and each page contains custom fields for latitude, longitude, logo, etc.

Read More

I have a map page where I get all pages of a certain template, loop through them and grab their custom field data, then use that to position markers on the map and create info windows, etc.

The problem is that it takes almost 10 seconds to complete. If I remove the calls to $cfs->get() for each iteration, it drops down to 1-2 seconds, which is far more reasonable, but then of course I only get a list of pages not any of the cfs data.

Basically I’m trying to speed this up and I need that custom field data to create markers on the map.

I know that each $cfs-get() is another query that connects the cfs_values table to the postmeta table and returns the results.

  • I’ve tried breaking it apart into smaller queries.

  • I’ve looked into a custom query that would grab all the cfs data at
    once, but am having no luck there.

Any ideas? And thanks.

Related posts