PRO: Show Page-Properties

Challenge: Show and use WordPress-Page-Properties like User-ID, Page-ID etc.


Solution: Create a new JCI-Template with name “showpageproperties” and URL “dummyrequest” (or an URL with JSON) and this twig-Code:

{% set pageprop = wp_get_page_properties() %}
get_current_user_id: {{pageprop.get_current_user_id}}
get_post.ID: {{pageprop.get_post.ID}}
all data:
{{pageprop |json_encode | e}}

Then you can use this Shortcode to display the properties:

[jsoncontentimporterpro nameoftemplate="showpageproperties"]

In Action:

get_current_user_id: 0
get_post.ID: 9540
all data:
{"get_permalink":"https://api.json-content-importer.com/pro-plugin-examples/pro-show-page-properties/","home_url":"https://api.json-content-importer.com","get_current_user_id":0,"userdata":false,"get_post":{"ID":9540,"post_author":"1","post_date":"2022-01-30 20:37:32","post_date_gmt":"2022-01-30 19:37:32","post_content":"<!– wp:paragraph –>\n<p><strong>Challenge:</strong> Show and use Wordpress-Page-Properties like User-ID, Page-ID etc.</p>\n<!– /wp:paragraph –>\n\n<!– wp:separator {\"opacity\":\"css\"} –>\n<hr class=\"wp-block-separator has-css-opacity\"/>\n<!– /wp:separator –>\n\n<!– wp:paragraph –>\n<p><strong>Solution:</strong> Create a new JCI-Template with name \"showpageproperties\" and URL \"dummyrequest\" (or an URL with JSON) and this twig-Code:</p>\n<!– /wp:paragraph –>\n\n<!– wp:enlighter/codeblock –>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{% set pageprop = wp_get_page_properties() %}\nget_current_user_id: {{pageprop.get_current_user_id}}\nget_post.ID: {{pageprop.get_post.ID}}\nall data:\n{{pageprop |json_encode | e}}</pre>\n<!– /wp:enlighter/codeblock –>\n\n<!– wp:paragraph –>\n<p>Then you can use this Shortcode to display the properties:</p>\n<!– /wp:paragraph –>\n\n<!– wp:enlighter/codeblock –>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[[ nameoftemplate=\"showpageproperties\"]]</pre>\n<!– /wp:enlighter/codeblock –>\n\n<!– wp:separator {\"opacity\":\"css\"} –>\n<hr class=\"wp-block-separator has-css-opacity\"/>\n<!– /wp:separator –>\n\n<!– wp:paragraph –>\n<p><strong>In Action:</strong></p>\n<!– /wp:paragraph –>\n\n<!– wp:paragraph –>\n<p>[ nameoftemplate=\"showpageproperties\"]</p>\n<!– /wp:paragraph –>\n\n<!– wp:separator {\"opacity\":\"css\"} –>\n<hr class=\"wp-block-separator has-css-opacity\"/>\n<!– /wp:separator –>\n\n<!– wp:paragraph –>\n<p>Remark: In the field \"post_content\" the string \"\" is removed, as this could be cause trouble in executing there shortcodes again and again</p>\n<!– /wp:paragraph –>","post_title":"PRO: Show Page-Properties","post_excerpt":"","post_status":"publish","comment_status":"closed","ping_status":"closed","post_password":"","post_name":"pro-show-page-properties","to_ping":"","pinged":"","post_modified":"2023-08-12 18:57:46","post_modified_gmt":"2023-08-12 16:57:46","post_content_filtered":"","post_parent":9627,"guid":"http://api.json-content-importer.com/?page_id=9540","menu_order":120,"post_type":"page","post_mime_type":"","comment_count":"0","filter":"raw"},"cpf":{"_edit_lock":["1691859467:1"],"_edit_last":["1"],"jci_pagehead":[""],"_jci_pagehead":["field_602bcf9303a35"],"jci_pagetitle":[""],"_jci_pagetitle":["field_602bcf9d03a36"],"_wp_page_template":["default"],"keyaa":[""],"_keyaa":["field_6202eda62a2d0"],"keybb":[""],"_keybb":["field_6202edaa2a2d1"]}}

Remark: In the field “post_content” the string “jsoncontentimporterpro” is removed, as this could be cause trouble in executing there shortcodes again and again