PRO: API curated.co, Access to JSON (sending Token) and generate CPT

Task:
Get data from curated.co via its API


Solution:

[jsoncontentimporterpro url=https://api.curated.co/PUBLICATION_KEY/api/v1/issue method=curlget method=curlget curloptions='CURLOPT_HTTPHEADER=Accept:application/json##Authorization:Token token=YOUR_API_KEY##Content-type:application/json']
issues: {{issues|length}}
{% for i in issues %}
{{i.published_at}}: </code></code><a href="{{i.url}}" target="_blank" rel="noopener">title: {{i.title}}</a><code>
{% endfor %}
[/jsoncontentimporterpro]

curated.co gives you a list of “issues”. You can generate for each issue a “WordPress page” (aka “Custom Post Type” or “Custom Post Page”) – for that, you need:

  • A JCI-template:
    There is all information on connecting the API and what data is displayed on the generated pages.
    Name: pattern-template
    URL: https://api.curated.co/PUBLICATION_KEY/api/v1/issue method=curlget method=curlget
    curloptions:
Accept:application/json##Authorization:Token token=YOUR_API_KEY##Content-type:application/json

twig-template:

summary: {{summary}}
number: {{number}}
title: {{title}}
url: {{url}}
published_at{{published_at | date("d.m.y, H:i")}}
  • A new “Custom Page Type” (CPT):
    At the JCI-Options, Tab “Custom Post Types” there is “JCI-own way: Create JCI-Custom Post Types”. With this, you can create a new CPT. You’re free to do this with many other Plugins.
    Add the following at “JCI-own way: Create JCI-Custom Post Types”, save it, and reload the page. Then there should be a new menu entry, “curatedname” (change ptname if you like).
    Important: WordPress’s “Permalink Settings” must be at “Post name” reloaded to register this new CPT. Check that at the general WordPress “Settings” > “Permalinks”
type=curatedtype;ptredirect=curatedredirect;ptname=curatedname;key=wqekjqw4758327
  • A WordPress-Page called “generating-page”: This page is in the generating page with a special JCI-Shortcode. Every time it is called, existing pages are deleted and new pages are created.
    • “loop” is the JSON path to the list of issues in the JSON: Other JSON, other value here!
[[jsoncontentimporterpro nameoftemplate=pattern-template mode=create createoptions='{"type":"curatedtype", "loop":"issues", "title":"Issue-number: {{number}}", "slugname": "slugname{{number}}", "deleteold":"yes"}']]

Preview the “generating-page”:
There should be “start looping” where the issues are used for generating pages.
The generated pages do have URLs like “…/curatedredirect/slug179/”: “curatedredirect” is the value of “ptredirect” (change as you like), “slug{{number}}” comes from the “createoptions”-JSON in the Shortcode of the generating-page. The same is with the title of the page: “Issue-number: {{number}}”

If the Click on a generated Page gives a “page not found”-error: The “Permalink Settings” of the WordPress must be at “Post name”. Check that at the general WordPress “Settings” > “Permalinks”