Developing the Terra Foundation’s Grants Database in WordPress
Authors: Marty Spellerberg, Principal Digital Strategist and Developer at Spellerberg Associates, and Jessica Warchall, former Director of Communications at Terra Foundation for American Art.
To learn more about the overall website redesign project, see the companion post.

The Terra Foundation for American Art’s public grants database was outdated and offered limited functionality for users seeking information about past awards or preparing new applications.
To address this issue, we developed a new database that presents grants connected to their primary and secondary grantee organizations, with advanced filtering and sorting capabilities. It integrates the foundation’s two core functions—grantmaking and its art collection—into a single, comprehensive, and searchable platform. We placed the grants database within a comprehensive content strategy that aligns with the foundation’s long-term vision. This approach highlights broader narratives through images of supported projects and collection loan installations, along with links to related stories and news.
The new database went live in early 2025 alongside a complete website refresh. The site operates on WordPress and includes a custom interactive map powered by Leaflet.
Our solution leverages WordPress’s core functionality—such as taxonomies, post relationships, and WP_Query—reserving custom SQL for complex meta-query logic. This approach aligns with the WordPress philosophy of building on existing capabilities and extending them only when necessary. It reduces development costs by allowing experienced WordPress developers to apply their existing knowledge when building and maintaining features. Additionally, it ensures compatibility with the WP Engine hosting environment, including its proprietary caching system and access to technical support for performance optimization.
A Data Model With Grants as the Primary Content
The system uses custom post types to manage grants and organizations. Organizations do not have dedicated pages; instead, selecting an organization redirects users to a grants archive filtered by that organization. This design keeps grants as the primary content, with organizations serving as metadata for filtering and display.
The “terra_grant” post type includes fields tailored for specific functions. The post title is reserved for internal administrative use, since many grants may share identical titles. A separate “grant_title” field contains the public-facing project name. Two relationship fields connect each grant to organizations: one for the grant recipient and another for additional venues, such as exhibition locations.
The “terra_organization” post type captures data on grant-receiving organizations. Rather than generating individual pages, each organization redirects to a filtered view of its relevant grants.
We organized grant types using a hierarchical taxonomy. Range fields give editors finer control over categorizations, and years are stored as a taxonomy rather than a date field, providing the foundation with flexibility to group grants as needed. For organizations, a hierarchical location taxonomy captures geographic data: Country, State, and City for U.S.-based organizations, and Country and City for those outside the United States.

Complex Sort Implementation
Standard WP_Query sorting handles basic fields like titles, dates, and simple meta values, but we needed to sort by taxonomy terms and formatted strings while managing cross-post relationships. To achieve this, we manipulated SQL directly using the posts_clauses filter.
For year-based sorting, we stored years as taxonomy terms rather than in post meta. We then implemented a manual JOIN with the terms tables through the posts_clauses filter, enabling sorting by term names.
Sorting by organization was the most complex scenario. It required joining the post meta to access the ACF relationship field, parsing serialized ACF data, joining another posts table to retrieve related organization titles, and using the MIN() function to select the alphabetically first organization when a grant involved multiple organizations.
The Two-Step Location Filter Process
Location filtering uses the most complex filter logic in the system and involves a two-step process. First, the system queries organizations based on the location taxonomy to retrieve their IDs. It then filters grants using those organization IDs through a meta query. This approach ensures accurate data representation while leveraging WordPress core functionality and centralizing complexity within the meta query.
We registered query variables for all filters: program, range, year, location, organization, sort by, and order. When a location filter is applied, the system queries organizations in that location, then constructs a meta query to identify grants associated with those organizations via primary or secondary relationships.
Building the Interactive Map with REST
We developed a custom REST API endpoint to access map data, accepting three parameters: program, year, and range. To improve performance, we implemented caching using one-hour transients. The cache key is generated from an MD5 hash of the request parameters and is automatically cleared when grants are updated.
The map uses MarkerCluster to group nearby locations. Cluster icons display the total number of grants for all markers within each cluster, with distinct styles differentiating clusters of fewer than 50 grants from those with 50 or more. Grants are aggregated by location on the server side before the data is sent to the client.

Overcoming High-Volume Query Bottlenecks
We used WP All Export to extract grants data from the previous system. The foundation’s team meticulously reconciled this data with their internal grants management system, which serves as their authoritative source. During reconciliation, they added secondary organizations, as the old data did not track these relationships.
We prepared import spreadsheets organized by location and hierarchy level to ensure proper nesting during the import, then used WP All Import for the actual data import. Foundation staff manually perform ongoing updates, as the low volume of data makes this approach practical.
Finally, to help maintain data quality, we developed a custom admin utility plugin. The plugin identifies grants that lack primary organizations, which can lead to incorrect ordering. It provides direct edit links to resolve orphaned grants.
Project Collaborators
For Spellerberg Associates: WordPress Development by Marty Spellerberg and Heather Sansone. Additional development by Trenisha Goslee.
For the Terra Foundation for American Art: Project leadership by Jessica Warchall.
Posted January 2026