Surrealist Artists

- You can use Airtable’s view designer to select the exact query you want to display.

This example shows how to filter the list of Artists for only those in the Surrealist genre. This filtering can be done in two ways: in PHP code (more complicated), or by creating a View in Airtable.

Let’s create a new view in Airtable called Surrealists; specify a one-line filter; hide all the fields except Name because we only need that for this example; sort the artist names alphabetically. Hiding fields (database columns) means that much less data will need to be sent to WordPress.

Steps in Airtable

  1. Select Artists table
  2. In the View box, click ENTER A NEW VIEW – Grid
  3. Change the view name to Surrealists
  4. Click Filter – Add a filter
  5. Use the filter dropdowns to show:
  6. “Where ‘Genre’ ‘has any of’ Surrealism”
  7. Click the little x to close the popup
  8. Click Hide Fields – Hide all
  9. Click Sort – Pick a field to sort on – Name – Apply

Page will display:

Alexander Calder
Edvard Munch
Frida Kahlo
Paul Klee

Code

Copy and paste this code into a page or post in WordPress.

The [insert_php] symbols will make the PHP code run on the page.

[insert_php]
$query = new AirpressQuery();
$query->setConfig("Artists_DB");
$query->table("Artists")->view("Surrealists");
$data = new AirpressCollection($query);

echo "<ul >";
foreach($data as $row){
      echo ("<li />");
      echo $row["Name"]."<br>";
      echo ("</li />");
}
echo "</ul >";
[/insert_php]