| 开发者 | antwork |
|---|---|
| 更新时间 | 2026年11月2日 01:40 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPL-3.0-or-later |
| 版权网址: | 版权信息 |
get_field() returns values that are not escaped, so every value is escaped for where it is printed (esc_html(), esc_url(), esc_attr(), wp_kses_post(), wp_get_attachment_image() for images), and nothing is printed when a field is empty. It follows the WordPress Coding Standards, runs on PHP 7.4 to 8.4, and names its variables after your fields.
It works with Advanced Custom Fields (free or Pro, version 6) and with Secure Custom Fields.
Features
single.php), inside the Loop.It needs Advanced Custom Fields (free or Pro, version 6) or Secure Custom Fields. Without one of them, it only shows a notice on the Plugins screen and does nothing else.
The users who may manage field groups: by default, administrators (the capability set for Advanced Custom Fields or Secure Custom Fields, manage_options unless changed).
The code is built from the saved field group, on the server. Save the field group after adding or changing fields to see their code.
Yes: every value is escaped for where it is printed, as the documentation of Advanced Custom Fields recommends. Text goes through esc_html(), links through esc_url(), attributes through esc_attr(), HTML content (Wysiwyg, Text Area with new lines) through wp_kses_post(), images through wp_get_attachment_image(), and the oEmbed field keeps its iframe only. Field names are written as plain PHP strings, so an unusual field name cannot break the code.
Repeater, Flexible Content, Gallery and Clone fields are covered by Antwork Field Code Pro, a separate plugin. The field types of other plugins are not covered yet: tell us which one you need in the support forum.
No. It reads the field group and shows code. It writes nothing in the database, makes no external request and stores no settings.
Yes. The filters awfc_field_renderers (cover or replace a field type), awfc_locations (add a location, such as an options page, with the post ID it passes to get_field()), awfc_location_post_id (change that post ID with the whole location rule), awfc_snippet_header and awfc_snippet_footer (add code before or after each snippet) are documented in the plugin's repository.
container), and the new filter awfc_location_post_id receives the whole location rule, such as the options page.args is read into $args_field, so that it never replaces the $args of a widget.