Starting to Think Through a Mapping Theme with ACF

We’re working with Dr. Nicole Turner on a mapping site that will accompany her upcoming book. There’s a lot of specifics there which we’re considering while trying to walk the fine line where what we make is also something we’ll be able to use with other people down the road. We want to generalize but not too much. I’m sketching out some early thinking here as a way to document it personally and to share it with Jeff (who’s thinking through the javascript side of things).1

Thinking About the Data

It seems that any mapping project would have three basic data types– People, Locations, and Events. People because humans are usually important in these scenarios. Locations being important in mapping and events for things that have limited duration. Matt described it well as the Who, When, and Where.

Those types could be associated with each other in multiple ways. A person might be associated with various locations and various events. Events might involve various people in various places. If I think too hard I’ll make this more complex.

The Custom Post Types & ACF Structure

I feel relatively good about those three main types so breaking down the details of what those big boxes should contain was the next consideration.

People

  • First Name
  • Middle Name
  • Last Name
  • Title
  • Description/Bio
  • Birth Event*
  • Death Event*
  • Events*
  • Locations*
  • Categories
  • Featured Image

Locations

  • Title
  • Latitude
  • Longitude
  • Description
  • Street Address
  • Events*
  • People*
  • Categories
  • Featured Image

Events

  • Title
  • Start
  • End
  • Description
  • Location*
  • People*
  • Categories
  • Featured Image

The items designated with the * are tied in via the ACF relationship field. This was something new to me but was super easy to set up. I turned on the ACF to Rest API plugin in addition to making sure these custom post types would appear in the WP REST API ‘show_in_rest’ => true.

Now I’ve got a decent interface for backend editing that makes adding connections between all these things as easy as clicking. We’ll refine things more going forward but it confirms some solid options that we can build on.
Animation showing association of one post with another.

The Data

With relationships we can either return the ID of the associated post or we can return the whole post object. Now at the REST endpoints (wp-json/wp/v2/event?_embed) for the various post types we’ll get JSON like this. I think this is going to be very nice for some of the related navigation construction.
JSON data structure showing the associated ACF post data.


1 I started to write him an email but it go very long and emails aren’t friendly to some of the formatting so I figured why not write a blog post.

Comments on this post

  1. Cog.Dog said on February 25, 2019 at 2:06 pm

    This looks super slick. I used to copy D’Arcy all the time, but now I am following your steps. Have not done much yet with ACF. Are there any Gutenburger issues?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Trackbacks and Pingbacks on this post

No trackbacks.

TrackBack URL