Help

Re: Airfields, a Wordpress plugin for managing custom fields in Airtable

3807 2
cancel
Showing results for 
Search instead for 
Did you mean: 

If you run a Wordpress website and you want to be able to easily pull data from Airtable into Wordpress, this is for you.

Airfields is a Wordpress plugin I’ve built that allows data from Airtable to be accessed using Wordpress’ get_post_meta and get_post_custom functions. There is also a shortcode you can use in the post editor that will output the value of whatever Airtable field you specify.

The way it works is that in the Airfields admin settings you will provide (App ID, API Key and) the name of an Airtable table and a field from that table in which either the post slug or the post ID will be stored. Then, any posts that match will have its custom data populated from the fields of the corresponding record from Airtable. This works with pages, posts, and any custom post type and can be used to display any field type Airtable supports.

This should be considered a beta. If you’re a Wordpress plugin developer interested in helping develop this plugin, let me know. And if you’re interested in testing out the plugin, go for it and let me know what changes you’d like to see.

https://github.com/chetmac/airfields/

Here’s what editing a page using shortcodes looks like:
9833d5f1102943f62d6c2e06b909a844ee77e262.png

Here’s the output on the website:
38322647b7fbadd1df06b788ae47052ff30c2a44.png

Here’s the Base it pulls from:
Pasted image

Here’s a code sample of how to use Airfields inside a PHP template file (the Airtable field as actually named, ‘Attachement’):

<?php
$attachment = get_post_meta($post->ID,"Attachment");
echo "<img src='".$attachment[0]["thumbnails"]["large"]["url"]."'>";
?>
17 Replies 17
Devin_Balkind
6 - Interface Innovator
6 - Interface Innovator

Very happy to see this type of functionality emerge. Trying to test it out now but can’t find the Airtable “App ID”. What is that?

Visit https://airtable.com/api and select the Airtable Base in question.

Then look in the address bar of your browser and you’ll see something like:
https://airtable.com/appaw53I4abVTeqVn/api/docs#curl/introduction

The App ID is the portion of the URL that begins with “app” and ends prior to the next front slash. So this App ID would be appaw53I4abVTeqVn

You could also look in the right-hand pane of that same page to find it:
7384ae3cd870a2260ced023c91061bc3f7c423aa.png

It’s the portion between https://api.airtable.com/v0/ and the name of the Airtable Table.

Devin_Balkind
6 - Interface Innovator
6 - Interface Innovator

Great. That worked. The settings page seems to register everything appropriately.

When trying to use the short code though I don’t get any results.

I added the code as described.

Airtable column that I want to appear is “Tools”.

I put the following text in a post:

Name: [airfield name=“Tools”]

When I publish and view, the only words on the page are "Name: "

For anyone else that might come across this, the solution was to append ?fresh=true to the page URL to force a fresh “fetch” from Airtable.

It’s true. Works great. Very interesting plugin with lots of possible uses.

One thing I noticed however is that, for fields that are linked to other AirTable sheets, it prints out a code instead of the value.

Ex.
AirTable Tools Type: Software
WordPress display of Tool Type: recrpNJrVHp0ioect

Can anything be done to display the value instead of the code?

At present, you’d need to create a Lookup field in Airtable that actually displays the value you want. Then reference that field in the Wordpress shortcode.

In the future, there will be an option/setting in Airfields that will allow you to specify Wordpress filters on each field that could do things like: retrieve associated records, merge two date records into a single duration, etc.

The biggest roadblock I’ve found as I’ve attempted to make my code “user friendly” via a plugin is displaying multiple linked records easily. For my projects, I’ve introduced a shortcode that includes an entire PHP file instead of simply outputting the field value. This allows me to loop, show defaults, and execute other logic on the field value before producing output.

This looks super cool. Thank you.

Stuart_Brameld
6 - Interface Innovator
6 - Interface Innovator

Awesome, really pleased to see this, it this makes so much sense!

Great job!

I have a client project that could be a good fit for this, and we work with lots of Wordpress developers that could help out, hence may be in touch in the next month or so.

Thanks for the feedback. Please do reach out. I’ve developed this much farther as straight code—this plugin is my attempt to make it more abstract and universally useful via admin settings.