Is there any documentation that you are following? Custom fields API
Is there a similar example that we can see? No
I have a PDF generator that generates PDF according to taxonomies, but i want it to be able to filter also by 2 fields assigned to a single CPT. These fields are selects.
The first part is to show the fields so we are able to implement the rest of the code.
In the PHP File:
$html .= '<div class="teste">';
echo types_render_field("wpfc-pais", array( ));
$html .= '</div>';
Returns blank in the Chrome Inspector (just the part of the php). Is there a way to implement this?
WARNING: This is in the backend, not the frontend.
Thank you
Hello,
The Types function types_render_field is only available on the front end, not in the back end, which is probably why checking the function exists appears to fix the issue.
Rather than use types_render_field you can retrieve the custom field directly from wp_postmeta using wordpress built-in function get_post_meta():
https://developer.wordpress.org/reference/functions/get_post_meta/
Note that Types fields are stored with a prefix of 'wpcf-', so the correct key to use in get_post_meta would be 'wpcf-pais".
Hi Luo,
I believe you miss interpreted what the question was, or perhaps i wasn't clear enough.
Postmeta retrieves the value of that field for a specific field.
This is what i want to see in the Backend: hidden link
A select filter.
Just the field itself so after that i can ask the developer to use that field so that it can retrieve CPT Listings based on that select and print them to PDF.
Where the field will appear, is not inside any post or any CPT related page.
Thanks
Your screenshot isn't in English, is it a custom select field?
Are you going to populate the options of this select field with some dynamic data?
If it is, you can try to setup custom PHP codes, use filter hook "wpt_field_options" to trigger a custom PHP function, in this function, setup the select option values as what you want.
for example this thread:
https://toolset.com/forums/topic/dynamically-populate-the-a-dropdown-list-with-taxonomy-terms/