Practitioner-plugin (WordPress)
De Practitioner-plugin is een maatwerk-plugin die eind 2017 is ontwikkeld voor een specifiek project. De achterliggende principes zijn echter vrij universeel, vandaar deze documentatie: Hoe maak je gebruik van een CPT - Custom Post Type?
Onderdelen
Er komt nogal wat bij kijken:
- Plugin zelf
- Child-theme van het gebruikte theme Hoshi
- Advanced Custom Fields PRO-plugin
- CPT-objectdefinitie (JSON- of PHP-bestand)
- Ingevoerde data.
Deployment
Voorbeeld: Hoe migreer je de plugin naar een nieuwe locatie?
Bronlocatie
Doellocatie
|
Onder de motorkap
Nog niet uitgezocht: Afbeeldingen (nog niet nodig gehad).
Export van data
- Ik weet niet hoe je CPT-gegevens gemakkelijk kunt exporteren - Ik heb het nog niet nodig gehad
- Op database-niveau is dit in ieder geval flink wat werk, omdat de data verspreid staat over twee tabellen, in meerdere velden.
Import van data - Ultimate CSV Importer
Opmaak importbestand
Dit betreft export vanuit LibreOffice Calc. Ongetwijfeld zijn er meer geldige mogelijkheden, maar dit werkt in ieder geval:
- UTF-8
- Tab-gescheiden of komma-gescheiden
- Alle velden omsloten met dubbele aanhalingstekens, of juist niet
Twee voorbeelden:
"Title" "firstname" "lastname" "description_short" "description_long" "city" "province" "website" "photo" "Jan1 Jan1 Achternaam" "Jan1" "Jan1 Achternaam" "Jan1 korte omschrijving" "Jan1 lange omschrijving" "Jan1 – Plaats" "Jan1 – Provincie" "Jan1 – Site" "Jan2 Jan2 Achternaam" "Jan2" "Jan2 Achternaam" "Jan2 korte omschrijving" "Jan2 lange omschrijving" "Jan2 – Plaats" "Jan2 – Provincie" "Jan2 – Site" "Jan3 Jan3 Achternaam" "Jan3" "Jan3 Achternaam" "Jan3 korte omschrijving" "Jan3 lange omschrijving" "Jan3 – Plaats" "Jan3 – Provincie" "Jan3 – Site"
en
Title firstname lastname description_short description_long city province website photo Jan1 Jan1 Achternaam Jan1 Jan1 Achternaam Jan1 korte omschrijving Jan1 lange omschrijving Jan1 – Plaats Jan1 – Provincie Jan1 – Site Jan2 Jan2 Achternaam Jan2 Jan2 Achternaam Jan2 korte omschrijving Jan2 lange omschrijving Jan2 – Plaats Jan2 – Provincie Jan2 – Site Jan3 Jan3 Achternaam Jan3 Jan3 Achternaam Jan3 korte omschrijving Jan3 lange omschrijving Jan3 – Plaats Jan3 – Provincie Jan3 – Site
Mapping - WordPress-velden
Cruciaal dat de kolom Title van een waarde is voorzien. Overige velden kun je negeren. Icm. de voorbeeldbestanden hierboven:
WP CSV ----------------- ----------------- Title Title Content -- Short Description --
Mapping - WordPress-WordPress Custom Fields
Dit zijn de velden die daadwerkelijk gebruikt worden.
WP CSV ----------------- ----------------- practitioner Title practitioner_city city practitioner_description_long description_long practitioner_description_short description_short practitioner_firstname firstname practitioner_lastname lastname practitioner_province province practitioner_website website
Image?
Geen idee.
Zie ook
Appendix: CPT-objectdefinitie
Het betreffende field group-exportbestand vanuit de Advanced Custom Fields PRO-plugin:
[ { "key": "group_5a44d8e93187a", "title": "Practitioners", "fields": [ { "key": "field_5a44db1c303ab", "label": "Practitioner", "name": "practitioner", "type": "group", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "layout": "block", "sub_fields": [ { "key": "field_5a44d90110811", "label": "Firstname", "name": "firstname", "type": "text", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "50", "class": "", "id": "" }, "default_value": "", "placeholder": "", "prepend": "", "append": "", "maxlength": "" }, { "key": "field_5a44da3910812", "label": "Lastname", "name": "lastname", "type": "text", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "50", "class": "", "id": "" }, "default_value": "", "placeholder": "", "prepend": "", "append": "", "maxlength": "" }, { "key": "field_5a44da5110813", "label": "Description (short)", "name": "description_short", "type": "textarea", "instructions": "Displayed in the Overview\/table", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "default_value": "", "placeholder": "", "maxlength": "", "rows": "", "new_lines": "" }, { "key": "field_5a44da70303a6", "label": "Description (long)", "name": "description_long", "type": "wysiwyg", "instructions": "Displayed on the single page", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "default_value": "", "tabs": "all", "toolbar": "full", "media_upload": 1, "delay": 0 }, { "key": "field_5a44daaa303a7", "label": "City", "name": "city", "type": "text", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "50", "class": "", "id": "" }, "default_value": "", "placeholder": "", "prepend": "", "append": "", "maxlength": "" }, { "key": "field_5a44dab4303a8", "label": "Province", "name": "province", "type": "text", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "50", "class": "", "id": "" }, "default_value": "", "placeholder": "", "prepend": "", "append": "", "maxlength": "" }, { "key": "field_5a44dad6303a9", "label": "Website", "name": "website", "type": "text", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "50", "class": "", "id": "" }, "default_value": "", "placeholder": "", "prepend": "", "append": "", "maxlength": "" }, { "key": "field_5a44daf7303aa", "label": "Photo", "name": "photo", "type": "image", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "50", "class": "", "id": "" }, "return_format": "array", "preview_size": "thumbnail", "library": "all", "min_width": "", "min_height": "", "min_size": "", "max_width": "", "max_height": "", "max_size": "", "mime_types": "" } ] } ], "location": [ [ { "param": "post_type", "operator": "==", "value": "practitioners" } ] ], "menu_order": 0, "position": "normal", "style": "default", "label_placement": "top", "instruction_placement": "label", "hide_on_screen": [ "the_content" ], "active": 1, "description": "" } ]