Print

PRO: Use Custom Post Fields

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.

E. g. a CPF “language” on one page with “en” and on another “de”.
Having a JCI-Shortcode on such a page, the value of the CPF can be used in the API-URL and in the twig-template.

With twig this works this way: Get the current pageID by wp_get_page_properties and then get the CPF by wp_get_custom_field_value:

{% 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>

more on that an an example: http://api.json-content-importer.com/build-api-url-with-use-custom-fields/

Was this article helpful?
0.5 out Of 5 Stars

1 rating

5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 100%
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
Previous PRO: Pagination
On this page: