Dynamic linking with php

Hello Everyone!

I am creating a custom wordpress site. I have an articles page that is looping through all of my articles using airtable as an api and cURL. When I click on the link for one of the articles, I would like it to bring me to that article’s specific page (dynamic template page).

How can i create a link that will grab the information for that specific airtable record?

Issue is that i would normally have to do record[‘0’][‘fields’][‘Name’]

however, since my page is dynamic, i cannot put the specific array [‘0’].

Hi @David_Delvin - not sure I totally understand your question, but on your articles page, I’m assuming you’re making a call to the articles table endpoint and getting back something like this:

{
    "records": [
        {
            "id": "recabc123",
            "fields": {
                "ID": 4,
                ...
            },
            "createdTime": "2019-10-25T14:35:05.000Z"
        },
        {
            "id": "recabc125",
            "fields": {
                "ID": 5,
                ...
            },
            "createdTime": "2019-10-25T14:47:27.000Z"
        },
        {
            "id": "recabc126",
            "fields": {
                "ID": 6,
                ...
            },
            "createdTime": "2019-10-25T14:56:18.000Z"
        }
    ],
    "offset": "recabc126"
} 

Using this you can loop through the articles and display whatever summary information you need. You can also include a link to a single article page for each record using the “id” key, e.g.

www.mysite.com/article/recabc123

or:

www.mysite.com/article?id=recabc123

On this page, you can retrieve a single record via the API using the record GET request, e.g.:

https://api.airtable.com/v0/YOUR_APP_ID/YOUR_TABLE_NAME/recabc123

Does that work for you?

JB