This pages shows you, how to set the Page-Title and Head-Tags out of JSON-data together with Custom Post Fields.
- Step 1: Add “Custom Post Fields” (CPF) to “Custom Post Type” (CPT)
You need two Custom Post Fields named “jci_pagetitle” and “jci_pagehead”. One way is to do that with ACF.
Connect these CPF with the CPT you want to set Title and Head, e. g. “Pages”. - Step 2: Custom Post Fields
Create a new Custom Post Page (CPP) out of the Custom Post Type you connected to the new Custom Post fields (CPF). Add some dummyvalues to the CPF and preview the CPP: The title should be the dummyvalue you set in “jci_pagetitle” - Step 3: Create a new JCI-Template
- name: addpagetitle
- Example-URL: https://api.json-content-importer.com/extra/json/meetup/1.json
- urlparam4twig: ename
- twig-Template-Text / twig:
{{ ("now"|date("H:i:s")) }} - name is {{urlparam.ename |e('html') | slice(0, 5)}} - {{ _context.0.name}}
- Step 4: Add shortcode with template
Insert the following into the CPF “jci_pagetitle”:begin-[[jsoncontentimporterpro nameoftemplate=addpagetitle]]-end
The preview of the page should have the HTML-Title<title>begin-name is Love Breakfast-end</title>
out of JSON-data. And out of first 5 characters of the GET-parameter “ename”, see here. - Step 5: Add Head-Tags to page, created out of JSON (Step 4 and the Shortcode there is required!)
Insert the following into the CPF “jci_pagehead”:
<meta name="event" content="{{urlparam.ename |e('html'|slice(0, 3) ) }}-{{ local_date|date("s:i;H-m/d/Y") }}: {{_context.0.name}}">#LF#<meta name="city" content="{{_context.0.venue.city}}">