Solution:
- Get your API-KEY and your PUBLICATION_KEY
- You need the PRO-Version of the JSON Content Importer-Plugin
- After installing the plugin in your WordPress add this to a page:
[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' parser=twig] issues: {{issues|length}} {% for i in issues %} {{i.published_at}}: title: {{i.title}} {% endfor %} [/jsoncontentimporterpro]
curated.co gives you a list of “issues”. You can generate for each issue a WordPress-pages (aka “Custom Post Type”) -for that you need:
- One WordPress-Pages called “generating-page”: This page is in the center and every time it is called new pages are created.
- One Plugin-template called “pattern-template”: There all information on how to connect the API is stored and what data is displayed on the generated pages.
- At least we have to tell your WordPress-Installation, that there is a new “Custom Page Type”.
- “generating-page”: Put this on a new WordPress-page: [jsoncontentimporterpro id=TEMPLATE_ID_PATTERN_TEMPLATE mode=create createoptions='{“type”:”curatedtype”, “loop”:”issues”, “title”:”Issue-number: {{number}}”, “slugname”: “slugname{{number}}”, “deleteold”:”yes”}’] (“loop” is the path to the list of issues in the JSON: Other JSON, other value here!) Add a “Custom Post Field” named “jci_uniquekey_createpost” with a random numer on that page (at least 10 chars). Preview that page: It says that the template with id=TEMPLATE_ID_PATTERN_TEMPLATE does not exist.
- Add a new plugin-template with these settings. The number of this template is TEMPLATE_ID_PATTERN_TEMPLATE :
- twig-code:
summary: {{summary}} number: {{number}} title: {{title}} url: {{url}} published_at{{published_at | date("d.m.y, H:i")}}
- unique-templatename: e.g. “curatedco-pagegenerator”
- URL:
https://api.curated.co/
PUBLICATION_KEY/api/v1/issues
- Method: CURL_GET
- Curloptions:
CURLOPT_HTTPHEADER=Accept:application/json##Authorization:Token token=YOUR_API_TOKEN##Content-type:application/json
- twig-code:
- Edit “generating-page”: Set TEMPLATE_ID_PATTERN_TEMPLATE with the numer of the generated plugin-template.
- Preview the “generating-page” again: You should get a message displayed “Pagetype not defined in plugin-options”. Click on the offered link will take you to the plugins options: Insert
type=curatedtype;ptredirect=curatedredirect;ptname=curatedname
there and save it. Click on “Custom Post Type”-Tab: You should see a new menuentry “curatedname” in the Admin-Menu: This is the place where the new pages will be (rename it via “ptname” as you like). - Preview the “generating-page” again: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. Same is with the title of the page: “Issue-number: {{number}}”
- If the URL 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”