I followed the guide for Creating a new field type and have a question about a topic which is not covered there:
I want to include the personalized HTML output of the field type in the template on the front end. Right now I define the visual part of the output in a template file, now I try to include that code in the plugin so I can render it in the template by calling get_field().
Is there a method similar to render_field() for rendering the field on the front end?
Note: I created a Openlayers backend map to store latitude and longitude values. Now I want to output a map with the marker position in the template.
You would use the format_value method for something like this.
Great, thanks! Using format_value() works out great to return a div as $value for rendering the map.
Where would I put the javascript in this case, is there something like input_admin_enqueue_scripts() but for front end?
There is also a commented out function (method) in the ACF example that will be called when scripts are enqueued where you can enqueue any custom scripts that you need.
Should be in the class-NAMESPACE-acf-field-FIELD-NAME-v5.php file right? I can’t find that, the functions which look promising are only being called on the edit screen…
oh, you want the script to be enqueued on the front end. That needs to be done when the field is output on the front end. You can either include inline code in the formatting or you could enqueue the script when it is formatted.