A WordPress-Page can have some Custom Post Fields (CPF). By that one WP-page can be almost identical to another, the only differencewould be a CPF.
see also at https://doc.json-content-importer.com/json-content-importer/pro-use-custom-post-fields/
Example:
- The JSON-API https://api.json-content-importer.com/extra/json/meetup/1.json
should be put together with CPF. So on one page 1.json is used, on another 2.json etc.. Triggered by CPF. - Define “keyaa” and “keybb” as Customfields and set values “meetup” and “1.json” (e. g. ACF-Plugin)
- Set up a JCI-Template:
- name: cpf-url
- twig-template:
wp_get_page_properties: get page ID
wp_get_custom_field_value: use page ID and keyaa / keybb to get values of CPF
{% set pageprop = wp_get_page_properties(debug, pageid) %} {% set pageid = jcipageparam.post.ID %} pageid: {{pageid}}<br> {% set valkeyaa = wp_get_custom_field_value(pageid, 'keyaa') %} CPF-keyaa: {{valkeyaa | json_encode }}<br> {% set valkeybb = wp_get_custom_field_value(pageid, 'keybb') %} CPF-keybb: {{valkeybb | json_encode }}<br> {% set url = "https://api.json-content-importer.com/extra/json/"~valkeyaa.0~"/"~valkeybb.0~"" %} url: {{url}}<br> {% for item in _context %} {{item.id}} {{item.name}} {{item.localized_name}} {% endfor %}
- URL: as 1st try use “dummyrequest”
But the magic comes here – calc the URL:
{% set pageprop = wp_get_page_properties() %} {% set pageid = pageprop.get_post.ID %} {% set valkeyaa = wp_get_custom_field_value(pageid, 'keyaa') %} {% set valkeybb = wp_get_custom_field_value(pageid, 'keybb') %} {% set url = "https://api.json-content-importer.com/extra/json/"~valkeyaa.0~"/"~valkeybb.0~"" %} {{url}}
- Shortcode for that template:
[[jsoncontentimporterpro nameoftemplate="cpf-url"]]
This should show you
url: https://api.json-content-importer.com/extra/json/meetup/1.json
In Action:
pageid: 866CPF-keyaa: [“meetup”]
CPF-keybb: [“1.json”]
url: http://api.json-content-importer.com/extra/json/meetup/1.json
Content from URL:
258386729 Love Breakfast
tcdgfqyzdbkb Drupal Coworking Day
258386398 Geeks – Februrary Edition
257739977 February 2019 Meetup
257183469 UG February Event
tpxglqyzdbsb Ignite Talks & Networking
258391683 public Event
fghgfhfghf D-Meetup