1. Overview
| Area | What you get |
|---|---|
| Post types | Every register_post_type() argument in seven tabs. Labels fill in automatically, there's a Dashicon picker, a live menu preview and seven presets. |
| Taxonomies | Every register_taxonomy() argument in seven tabs, including the default term and the meta box style. |
| Field groups | 36 field types, drag-and-drop nesting, conditional logic, validation and 23 location rule types. Groups that depend on the template, format, categories, parent or status appear and disappear live while you edit. |
| PRO fields | Repeater (table, block or row layout, pagination), Flexible Content (rename and disable layouts per row), Gallery, Clone. |
| Relationships | Bidirectional relationships between posts, users and terms. |
| Options pages | Top-level pages and sub pages, each with its own capability, icon, storage ID and button labels. |
| Where fields appear | Posts, pages, custom post types, terms, users (profile, add and register forms), attachments, comments, menus, menu items, classic widgets, options pages and field blocks. |
| Developer API | sgcf_* template functions, optional ACF aliases, PHP registration, front-end forms. |
| Integrations | REST API, shortcode, the Custom Field Value block, block bindings, ACF-style field blocks, WP-CLI. |
| Workflow | Local JSON with sync, JSON and PHP export, import from Sysgage, ACF / ACF Pro and CPT UI, database cleanup. |
How it is built:
- No external services or CDNs at runtime. The only exception is the Google Maps script, which loads only for Google Map fields.
- No build step and no Composer dependencies.
- Uses only the JavaScript libraries that ship with WordPress.
- Every string is translatable (text domain
sysgage-custom-fields). - On servers older than PHP 7.4 or WordPress 6.4, the plugin shows an admin notice and does not load.
2. Admin screens
Everything is under the Custom Fields menu (just below Settings). Each screen has a header with the logo, the page title, primary actions and tabs to every other screen. On small screens the tabs scroll sideways. All plugin styles are scoped to the plugin's own screens and boxes, so the rest of wp-admin keeps its native look.
| Screen | Slug | Capability |
|---|---|---|
| Overview | sgcf | manage_options (filter sgcf/admin/capability) |
| Field Groups | sgcf-field-groups | same |
| Post Types | sgcf-post-types | same |
| Taxonomies | sgcf-taxonomies | same |
| Options Pages | sgcf-options-pages | same |
| Tools | sgcf-tools | same |
| Settings | sgcf-settings | same |
On list screens, add &action=new to the URL to create an item, or &action=edit&key={key} to edit one.
2.1 Overview
- Welcome banner with "New Field Group" and "New Post Type" buttons.
- Stat tiles: field groups, fields, post types, taxonomies and options pages (each with its active count).
- Recently updated: definitions with their type, status badge and how long ago they changed.
- Getting started checklist:
- build a field group
- create a post type
- add a taxonomy
- create an options page
- enable Local JSON
- Quick actions.
- System status:
- plugin, WordPress and PHP versions
- pretty permalinks
- Local JSON folder (writable, not writable, or not created yet)
- REST API fields
- shortcode
- ACF function aliases (reports when ACF is active, or when they are shared with Sysgage Content Types)
- Template functions cheat sheet with copy buttons. It covers:
- displaying a field
- looping a repeater
- flexible content
- options page values
- term and user fields
- image fields
- the shortcode
- registering in PHP Add your own snippets with the
sgcf/admin/snippetsfilter.
2.2 Post types
List screen. Each row shows:
- the menu icon and label
- the slug
- an active/inactive toggle
- the post count
- the attached taxonomies
- a "Local" badge for definitions that come from PHP or JSON
You can search and filter by All / Active / Inactive. Row actions are Edit, Duplicate, Delete and View posts.
"Add Post Type" presets. Some presets can also create a matching field group in the same step.
| Preset | What it sets up |
|---|---|
| Blank | Nothing, start from scratch |
| Portfolio | A portfolio post type |
| Events | An events post type |
| Testimonials | A testimonials post type |
| Team Members | Supports title, editor, thumbnail and page attributes |
| Products / Services | Supports title, editor, thumbnail, excerpt and page attributes |
| FAQ | Supports title, editor and page attributes |
The editor has seven tabs:
| Tab | Settings |
|---|---|
| Basic | Plural and singular labels; a post type key generated from the singular label, checked as you type (max 20 characters, a-z 0-9 _ -, no reserved or existing names); public; hierarchical; description |
| Labels | All 29 WordPress labels, filled in automatically, with a "Regenerate" button |
| Visibility & Menu | show_ui, show in menu or under a parent menu, menu position, a Dashicon picker with search, admin bar, nav menus, exclude from search, publicly queryable |
| Supports & Taxonomies | Feature cards: title, editor, author, thumbnail, excerpt, trackbacks, custom-fields, comments, revisions, page-attributes, post-formats. Taxonomy multi-select (core and custom). |
| URLs | Permalink rewrite (post type key, custom slug or none), with front, feeds, pages, archive, archive slug, query variable |
| REST & Permissions | Show in REST, REST base, namespace, controller class, custom capability names, delete with user, can export |
| Editor | "Enter title here" text, block template (JSON), template lock, meta box callback |
A sidebar card shows a live preview of the admin menu item, along with the Save, Delete and Active controls.
Security note: the
register_meta_box_cbandrest_controller_classfields name PHP code to run. They are read-only for users withoutunfiltered_html, and on multisite only super admins can edit them. You can change this with thesgcf/store/can_set_codefilter.
2.3 Taxonomies
The list screen works like the post types list.
Presets: Blank, Category style and Tag style.
The editor has seven tabs:
| Tab | Settings |
|---|---|
| Basic | Labels and key (max 32 characters), the post types to attach to (all public post types, including ones you created here), public, hierarchical |
| Labels | All taxonomy labels, filled in automatically |
| Visibility | Show UI, menu, nav menus, tag cloud, quick edit, admin column |
| URLs | Rewrite slug, with front, hierarchical URLs, query variable |
| REST & Permissions | REST settings, the four term capabilities, sort |
| Default Term | Enable, name, slug, description |
| Meta Box | Default, custom callback or disabled |
2.4 Field groups
List screen. Each row shows:
- the title and description
- the number of fields
- a summary of the location rules
- an active toggle
- a "Local JSON" badge, a "PHP" badge, or "Sync available" / "Sync: new"
Row actions are Edit, Duplicate, Export JSON and Delete. You can search and filter.
Builder:
- Title in a large input. The group key and field count appear underneath.
- Field list:
- Drag fields to reorder them or to nest them in repeaters, groups and flexible content layouts.
- You can also move fields with the keyboard: focus a handle and use the arrow keys.
- Each row shows its order number, label, name, a type badge with an icon, and buttons for Duplicate, Move (to another field list in the group, such as a repeater's sub fields) and Delete.
- "Expand all" and "Collapse all" open or close every row.
- "Add Field" opens a type picker:
- six categories
- search
- an icon, description and preview for each type
- keyboard navigation
- Field settings are split into General, Validation, Presentation and Conditional Logic tabs.
- The field name is generated from the label (snake_case) until you edit it yourself.
- "Change field type" keeps the common settings and the ones the new type understands. It asks for confirmation before it drops sub fields.
- Flexible content layouts: each layout can be named, labelled, given a display mode (block, table or row) and a min/max, and can be duplicated or reordered.
- Location Rules: build OR groups of AND rules. See section 4.
- Settings sidebar: | Setting | Options | |—|—| | Active | On / off | | Position | High (after title), Normal (after content), Side | | Style | Standard (meta box), Seamless | | Label placement | Top, Left | | Instruction placement | Below labels, Below fields | | Order No. | Number | | Description | Text | | Hide on Screen | permalink, content editor, excerpt, discussion, comments, revisions, slug, author, format, page attributes, featured image, categories, tags, send trackbacks | | Show in REST API | On / off |
- Saving: a sticky Save Changes bar, a warning if you leave with unsaved changes, and checks before saving (required labels and names, unique names at each level, unique layout names).
- Local and PHP groups:
- Groups loaded from a JSON file can be edited. Saving one stores it in the database.
- Groups registered in PHP are read-only. Duplicate one to get an editable copy.
2.5 Options pages
The list screen works like the other lists. The editor has three tabs:
| Tab | Settings |
|---|---|
| General | Page title, menu title, menu slug, description |
| Menu | Parent: top level, Settings, Tools, Appearance, any admin menu, or another options page. Also capability, position, icon (Dashicon picker or URL) and "redirect to first sub page". |
| Storage & Buttons | post_id storage prefix (default options), autoload, Update button label, updated message |
The options page itself shows the matching field groups as postboxes, with a sticky Update box in the side column.
2.6 Tools
| Tab | Purpose |
|---|---|
| Export | Pick any mix of field groups, post types, taxonomies and options pages. Then either download a JSON file or click Generate PHP to get sgcf_register_post_type(), sgcf_register_taxonomy(), sgcf_add_options_page() and sgcf_add_local_field_group() code wrapped in add_action( 'sgcf/init', … ), with a copy button. |
| Import | Upload a JSON file. Accepted formats: Sysgage exports, ACF / ACF Pro exports (field groups, post types, taxonomies, options pages), and CPT UI exports (post types, taxonomies, or the combined file). For existing items you can Skip, Overwrite it, or Duplicate. You can also choose "Import as inactive". |
| Local JSON Sync | Lists JSON files that are newer than the database copy, or not in the database at all. Review shows the definition; Sync imports it. |
| Database Cleanup | Finds orphaned _name reference meta left behind by deleted fields and removes it. You can also delete the stored values. Asks for confirmation first. |
2.7 Settings
See section 16.
2.8 Edit screens (where editors enter data)
- Posts, pages and custom post types:
- Meta boxes in the block editor and the classic editor, in the high, normal or side position, with standard or seamless style.
- Tabs and accordions inside groups.
- Inline validation.
- In the block editor, Publish or Update stops with a message that names any empty required fields. Nothing is locked while you type, and required fields in groups that are hidden for the current template or categories are ignored.
- Drafts are not validated (filter
sgcf/screens/validate_post).
- Terms: fields on the add and edit forms.
- Users: fields on the profile, edit, add-new and front-end registration forms.
- Media: fields in the attachment edit screen and the media modal.
- Comments: a meta box on the comment edit screen.
- Menus: fields on each menu item and in the menu settings.
- Widgets: fields inside classic widget forms.
- Options pages: see section 6.
When field groups are on screen, the core "Custom Fields" meta box is removed, as ACF does. Filter: sgcf/screens/remove_wp_meta_box.
3. Field types
3.1 Settings every field has
| Setting | Key | Default |
|---|---|---|
| Label | label | '' |
| Name (meta key) | name | '' |
| Key | key | field_… (generated) |
| Type | type | text |
| Instructions | instructions | '' |
| Required | required | false |
| Conditional logic | conditional_logic | false |
| Wrapper width % / class / id | wrapper | {width:'', class:'', id:''} |
| Default value | default_value | '' |
| Show in REST | show_in_rest | true |
| Read only | readonly | false |
| Bidirectional (Relationship, Post Object, User, Taxonomy; Advanced tab) | bidirectional, bidirectional_target | false, [] |
Settings are grouped in five tabs in the field group builder: General, Validation, Presentation, Conditional Logic and Advanced.
The sgcf_get_field() return values below assume the default $format_value = true. With false, you get the raw stored value.
3.2 Basic
| Type | Type-specific settings (defaults) | sgcf_get_field() returns |
|---|---|---|
Text text | placeholder, prepend, append, maxlength | String. Inline HTML is kept, like ACF: users without the unfiltered_html capability get it filtered with wp_kses_post(). Line breaks are removed. |
Text Area textarea | placeholder, maxlength, rows, new_lines ('' | wpautop | br) | String, with wpautop() or nl2br() applied according to new_lines. HTML is filtered with wp_kses_post for users without unfiltered_html. |
Number number | min, max, step, placeholder, prepend, append | int or float; '' when empty |
Range range | min, max, step, prepend, append | int or float; '' when empty |
Email email | placeholder, prepend, append | String |
URL url | placeholder | String |
Password password | placeholder, prepend, append | String. Never exposed through REST, the shortcode, the block or bindings. |
3.3 Content
| Type | Settings (defaults) | Returns |
|---|---|---|
Image image | return_format (array | url | id, default array; new fields use the "Default image return format" setting), library (all | uploadedTo), preview_size (medium), min_width, min_height, min_size, max_width, max_height, max_size (MB), mime_types | array: attachment array (see below). url: string. id: int. false when empty. |
File file | return_format (array), library, min_size, max_size, mime_types | Same as Image (no sizes, width or height for non-images) |
WYSIWYG Editor wysiwyg | tabs (all | visual | text), toolbar (full | basic), media_upload (1), delay (0) | HTML string run through the sgcf_the_content filter: wptexturize, wpautop, shortcodes, embeds, wp_filter_content_tags |
oEmbed oembed | width, height | Embed HTML, or the URL if it can't be embedded |
Gallery gallery | return_format (array), library, insert (append | prepend), preview_size, min, max, the same size, dimension and MIME limits as Image | Array of attachment arrays, URLs or IDs; false when empty |
Attachment array keys:
ID,id,title,filename,filesize,url,link,altauthor,description,caption,name,status,uploaded_todate,modified,menu_ordermime_type,type,subtype,icon- images only:
width,height, andsizes, which holds{size},{size}-widthand{size}-heightfor each size
Filter the array with sgcf/attachment_array.
3.4 Choice
choices are entered one per line as value : label.
| Type | Settings (defaults) | Returns |
|---|---|---|
Select select | choices, default_value, return_format (value | label | array), allow_null, multiple, ui (searchable select), placeholder | Single: value, label, or ['value'=>…, 'label'=>…]. Multiple: an array of these. |
Checkbox checkbox | choices, default_value, return_format, allow_custom, layout (vertical | horizontal), toggle (adds a "Toggle all" box) | Array of values, labels or value/label arrays |
Radio Button radio | choices, default_value, return_format, allow_null, other_choice, layout | Value, label or value/label array |
Button Group button_group | choices, default_value, return_format, allow_null, layout (horizontal) | Same as Radio |
True / False true_false | default_value (0), message, ui (switch, default on), ui_on_text, ui_off_text | bool |
3.5 Relational
| Type | Settings (defaults) | Returns |
|---|---|---|
Link link | return_format (array | url) | ['title'=>…, 'url'=>…, 'target'=>…] or a URL; false when empty |
Post Object post_object | post_type[], post_status[], taxonomy[] (taxonomy:slug filters), return_format (object | id), allow_null, multiple | WP_Post or int; an array of them when multiple; false when empty. Trashed posts are skipped. |
Page Link page_link | post_type[], post_status[], taxonomy[], allow_archives (1), allow_null, multiple | Permalink string (or array of strings); archive URLs are returned as they are |
Relationship relationship | post_type[], post_status[], taxonomy[], return_format (object), min, max, filters (search, post_type, taxonomy), elements (featured_image) | Array of WP_Post or IDs; false when empty |
Taxonomy taxonomy | taxonomy (category), field_type (checkbox | multi_select | radio | select), return_format (id | object), allow_null, add_term (1), save_terms, load_terms | Checkbox / multi select: array of IDs or WP_Term. Radio / select: one ID or WP_Term. false when empty. |
User user | role[], return_format (array | object | id), allow_null, multiple | array: ID, user_firstname, user_lastname, nickname, user_nicename, display_name, user_email, user_url, user_registered, user_description, user_avatar. object: WP_User. id: int. An array of these when multiple. |
save_terms sets the selected terms on the post itself. load_terms reads the post's terms instead of meta. "Create Terms" (add_term) lets editors add new terms from inside the field.
3.6 Advanced
| Type | Settings (defaults) | Stored as | Returns |
|---|---|---|---|
Google Map google_map | center_lat (-37.81411), center_lng (144.96328), zoom (14), height (400) | Array | Array with address, lat, lng, zoom, place_id, name, street_number, street_name, city, state, post_code, country, country_short (empty parts are left out); false when empty. Needs an API key. |
Date Picker date_picker | display_format (d/m/Y), return_format (d/m/Y), first_day (1) | Ymd | Date string in return_format (site timezone) |
Date Time Picker date_time_picker | display_format, return_format (d/m/Y g:i a) | Y-m-d H:i:s | Formatted string |
Time Picker time_picker | display_format, return_format (g:i a) | H:i:s | Formatted string |
Color Picker color_picker | enable_opacity, return_format (string | array) | Hex or rgba() | String, or ['red','green','blue','alpha'] |
Icon Picker icon_picker | tabs (dashicons, url), return_format (string | array) | {type, value} | dashicons-… or the URL; or ['type'=>'dashicons'|'url', 'value'=>…] |
3.7 Layout
| Type | Settings | Returns |
|---|---|---|
Message message | message, new_lines, esc_html | No value (display only) |
Accordion accordion | open, multi_expand, endpoint | No value |
Tab tab | placement (top | left), selected (open by default), endpoint (start a new tab group) | No value |
Group group | layout (block | table | row), sub_fields | Array of sub field values keyed by sub field name |
Repeater repeater | sub_fields, min, max, layout (table | block | row, default table), button_label, collapsed (sub field shown when a row is collapsed), pagination, rows_per_page (20) | List of rows, each keyed by sub field name; false when empty |
Flexible Content flexible_content | layouts (each with name, label, display, min, max, sub_fields), min, max, button_label | List of rows, each with acf_fc_layout and sgcf_layout (the layout name) plus sub values by name; false when empty |
Clone clone | clone (field keys and/or group keys), display (seamless | group), layout, prefix_label, prefix_name | Array of the cloned values keyed by name. With seamless display, the cloned fields are also stored as siblings, so you can read them by their own names (with the clone's name as a prefix if prefix_name is on). |
Rows in a repeater or flexible content field can be added, duplicated, collapsed, reordered by dragging and removed. min and max are enforced both in the browser and on the server.
Flexible content: rename and disable layouts. Each flexible content row has two extra buttons in its header:
- Rename (pencil): give the row its own label, such as "Spring sale banner", so long pages stay easy to scan. The label is only shown in the editor, next to a small badge with the layout name. Clear it to go back to the layout name.
- Disable / enable (eye): a disabled row keeps its content in the editor (shown dashed and faded with a "Disabled" badge) but is skipped on the site.
have_rows(),get_field(), the shortcode, blocks and the REST API all leave it out, so you can prepare or pause a section without deleting it.
Both are stored per row in the hidden _{field_name}_layout_meta meta value.
3.8 Custom field types
Extend SGCF_Field_Type and register your class on sgcf/register_field_types:
add_action( 'sgcf/register_field_types', function () {
class My_Field_Rating extends SGCF_Field_Type {
public function __construct() {
$this->name = 'rating';
$this->label = __( 'Rating', 'my-theme' );
$this->category = 'choice';
$this->icon = 'dashicons-star-filled';
$this->defaults = array( 'max_stars' => 5 );
}
public function render_input( array $field, $value, string $input_name ): void {
printf( '<input type="number" min="0" max="%d" name="%s" value="%s" />',
(int) $field['max_stars'], esc_attr( $input_name ), esc_attr( $value ) );
}
public function format_value( $value, array $field, $object_id ) {
return (int) $value;
}
}
SGCF_Fields::register( new My_Field_Rating() );
} );
You can override these methods: get_settings(), sanitize_value(), validate_value(), format_value(), load_value(), rest_schema(), enqueue_assets() and is_empty().
3.9 Bidirectional relationships
Turn on Bidirectional in the Advanced tab of a Relationship, Post Object, User or Taxonomy field and choose one or more Target Fields. When an editor links item A to item B, B's target field gets a link back to A. When the link is removed, the link back is removed too.
- Works between posts, users and terms in any combination. For example, a Relationship field "Speakers" on events can update a Relationship field "Events" on users.
- A field can target itself for a self-referencing link ("Related events" on both sides).
- When the target field holds a single value (Post Object or User without "Select multiple"), the item it pointed to before loses its link, so both sides stay consistent.
- A target's Maximum is respected: a link back is skipped instead of overflowing it.
- Only top-level fields take part (not fields inside a repeater, flexible content, group or clone), the same rule as ACF.
- A signed-in user only updates items they are allowed to edit (filter
sgcf/bidirectional/can_update). Saves without a user, such as WP-CLI or imports, always sync. - The action
sgcf/bidirectional/syncedfires after each sync with the IDs that were added and removed.
The settings use ACF's keys (bidirectional, bidirectional_target), so bidirectional fields imported from ACF keep working.
4. Location rules
A field group appears on a screen when any rule group matches. Within a group, all rules must match. Every rule offers the operators == (is equal to) and != (is not equal to).
| Param | Group | Values |
|---|---|---|
post_type | Post | Any post type that has a UI |
post_template | Post | Theme templates for posts, grouped by post type |
post_status | Post | publish, future, draft, pending, private |
post_format | Post | standard, aside, chat, gallery, link, image, quote, status, video, audio |
post_category | Post | Category terms |
post_taxonomy | Post | Any term, as taxonomy:slug |
post | Post | A specific post |
page_template | Page | Page templates |
page_type | Page | front_page, posts_page, top_level, parent, child |
page_parent | Page | A specific parent page |
page | Page | A specific page |
current_user | User | logged_in, viewing_front, viewing_back |
current_user_role | User | Roles |
user_form | User | all, add, edit (Add / Edit), register |
user_role | User | Role of the user being edited |
taxonomy | Forms | Term add/edit screens of a taxonomy, or all |
attachment | Forms | All, or a MIME type or group |
comment | Forms | All, or comments on a post type |
widget | Forms | All, or a widget ID base |
nav_menu | Forms | All, or a menu or menu location |
nav_menu_item | Forms | All, or the items of a menu |
options_page | Forms | An options page's menu slug |
block | Forms | A field block (see 13.3) |
New field groups start with post_type == post.
Live matching while editing. Rules about the page template, post format, categories and other terms, the parent page, the page type and the post status can change while a post is being edited. Field groups that use them are shown and hidden as soon as the change is made, in both the block editor and the classic editor, without saving first. For example, a "Landing page extras" group set to page_template == landing appears the moment the editor picks that template.
A group that is waiting to appear keeps its inputs disabled and is marked as inactive, so its values are not saved and its required fields do not block saving. Turn this off with add_filter( 'sgcf/screens/live_location', '__return_false' );.
Adding a custom rule. Register it with sgcf/location/rule_types, offer its values with sgcf/location/rule_values/{param}, and do the matching in sgcf/location/match/{param}. The matching filter must handle the operator itself.
add_filter( 'sgcf/location/rule_types', function ( $types ) {
$types['site_language'] = array(
'label' => 'Site language',
'group' => 'Other',
'operators' => array( '==' => 'is equal to', '!=' => 'is not equal to' ),
);
return $types;
} );
add_filter( 'sgcf/location/rule_values/site_language', fn() => array( 'en_US' => 'English', 'de_DE' => 'German' ) );
add_filter( 'sgcf/location/match/site_language', function ( $result, $rule, $screen ) {
$match = get_locale() === $rule['value'];
return '==' === $rule['operator'] ? $match : ! $match;
}, 10, 3 );
5. Conditional logic
Any field can be shown or hidden based on the values of other fields. Conditions are OR groups of AND rules, built on the field's Conditional Logic tab. The field select offers the fields that come before this one. When the target is a choice field, the value select shows its choices.
| Operator | Meaning |
|---|---|
== / != | Value is (or is not) equal. For multi-value fields: the list contains (or does not contain) the value. |
==empty / !=empty | Has no value / has any value |
==contains / !=contains | Value contains (or does not contain) the text |
==pattern | Value matches a regular expression |
> / < | Numeric comparison. For multi-value fields, the number of selected items is compared. |
- Scope. Conditions inside a repeater row, group or layout look at that row first, then at the whole form.
- Hidden fields are disabled, so they are not submitted.
- Server side: the same rules are evaluated on save, and hidden fields skip validation. This means a hidden required field never blocks saving.
Stored format, the same as ACF's:
'conditional_logic' => array(
array( // OR group
array( 'field' => 'field_abc123', 'operator' => '==', 'value' => 'yes' ), // AND
),
),
6. Options pages
Options pages give you global fields (contact details, a footer, a banner) that are stored in wp_options.
- Create the page under Custom Fields > Options Pages, or in code (see section 8).
- Create a field group with the location rule Options Page == {menu slug}.
- Read the values with
'options', or with the page's custompost_id, as the object ID.
$phone = sgcf_get_field( 'company_phone', 'options' );
if ( sgcf_have_rows( 'social_links', 'options' ) ) {
while ( sgcf_have_rows( 'social_links', 'options' ) ) {
sgcf_the_row();
printf( '<a href="%s">%s</a>', esc_url( sgcf_get_sub_field( 'url' ) ), esc_html( sgcf_get_sub_field( 'network' ) ) );
}
}
Options page settings:
page_title,menu_title,menu_slugparent_slug: empty means a top-level page. Otherwise use a menu file such asoptions-general.phpor another page's slug.capability(defaultedit_posts)position,icon_urlredirect: a top-level page opens its first sub pagepost_id(defaultoptions)autoload(defaultfalse)update_button,updated_message,description
Storage. Values are stored as {post_id}_{name}, with the field key in _{post_id}_{name} (for example options_company_phone). This is the same as ACF.
Visitors. The shortcode, the block and block bindings show options values only to users who can open that options page. To show a page's values to every visitor, tick it under Settings > Integrations > Public options pages. Only fields placed on that page are shown.
7. Template function reference
Each function takes a selector: a field name ('subtitle') or a field key ('field_65f1c2a9b3d4e').
Most functions also take an optional $post_id:
| Value | Object |
|---|---|
false / 0 / omitted | The current post in the loop, or the queried object |
123 or a WP_Post | A post |
'term_5', '{taxonomy}_5' (e.g. 'category_5') or a WP_Term | A term |
'user_2' or a WP_User | A user |
'comment_3' or a WP_Comment | A comment |
'options' or a custom options post_id | An options page |
'menu_7', 'nav_menu_item_9' | A menu or a menu item |
7.1 Reading values
| Function | Description |
|---|---|
sgcf_get_field( $selector, $post_id = false, $format_value = true, $escape_html = false ) | Returns the value. If the selector is not a registered field, returns the raw meta value, or null if there is none. $escape_html runs strings through wp_kses_post. |
sgcf_the_field( $selector, $post_id = false, $format_value = true ) | Echoes the value through wp_kses_post. Arrays are joined with , . Posts print their title, and links and images print their URL. |
sgcf_get_fields( $post_id = false, $format_value = true ) | Returns all values as name => value, or false |
sgcf_get_field_object( $selector, $post_id = false, $format_value = true, $load_value = true ) | Returns the field definition with its value, or false |
sgcf_get_field_objects( $post_id = false, $format_value = true ) | Returns name => field object, or false |
<h2><?php echo esc_html( sgcf_get_field( 'subtitle' ) ); ?></h2>
<?php $cover = sgcf_get_field( 'cover_image' ); // Image, return format "array" ?>
<?php if ( $cover ) : ?>
<img src="<?php echo esc_url( $cover['sizes']['large'] ); ?>" alt="<?php echo esc_attr( $cover['alt'] ); ?>" />
<?php endif; ?>
<?php foreach ( (array) sgcf_get_field( 'related_books' ) as $book ) : // Relationship, return format "object" ?>
<a href="<?php echo esc_url( get_permalink( $book ) ); ?>"><?php echo esc_html( get_the_title( $book ) ); ?></a>
<?php endforeach; ?>
7.2 Row loops: repeater, flexible content and group
| Function | Description |
|---|---|
sgcf_have_rows( $selector, $post_id = false ) | true while rows remain. Inside a row, call it with a sub field name to start a nested loop. |
sgcf_the_row( $format = false ) | Moves to the next row and returns it (raw by default, or formatted and keyed by name) |
sgcf_get_row( $format = false ) | Returns the current row |
sgcf_get_sub_field( $selector, $format_value = true ) | Returns a sub field value from the current row |
sgcf_the_sub_field( $selector ) | Echoes a sub field value |
sgcf_get_sub_field_object( $selector, $format_value = true ) | Returns the sub field definition and its value |
sgcf_get_row_layout() | Returns the layout name of the current flexible content row |
sgcf_get_row_index() | Returns the current row number (1-based) |
sgcf_reset_rows() | Leaves the current loop early (call it before break) |
Repeater:
<?php if ( sgcf_have_rows( 'chapters' ) ) : ?>
<ol>
<?php while ( sgcf_have_rows( 'chapters' ) ) : sgcf_the_row(); ?>
<li>
<strong><?php sgcf_the_sub_field( 'title' ); ?></strong>
<span><?php echo (int) sgcf_get_sub_field( 'pages' ); ?> pages</span>
<?php // Nested repeater ?>
<?php if ( sgcf_have_rows( 'sections' ) ) : ?>
<ul>
<?php while ( sgcf_have_rows( 'sections' ) ) : sgcf_the_row(); ?>
<li><?php echo esc_html( sgcf_get_sub_field( 'heading' ) ); ?></li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
</li>
<?php endwhile; ?>
</ol>
<?php endif; ?>
You can also work with the whole array:
foreach ( (array) sgcf_get_field( 'chapters' ) as $i => $row ) {
echo esc_html( ( $i + 1 ) . '. ' . $row['title'] );
}
Flexible content:
<?php while ( sgcf_have_rows( 'page_sections' ) ) : sgcf_the_row(); ?>
<?php switch ( sgcf_get_row_layout() ) :
case 'hero': ?>
<section class="hero">
<h1><?php echo esc_html( sgcf_get_sub_field( 'headline' ) ); ?></h1>
<?php $bg = sgcf_get_sub_field( 'background' ); ?>
<?php if ( $bg ) echo wp_get_attachment_image( $bg['ID'], 'full' ); ?>
</section>
<?php break;
case 'text_block': ?>
<section class="text"><?php echo wp_kses_post( sgcf_get_sub_field( 'body' ) ); ?></section>
<?php break;
case 'quote': ?>
<blockquote><?php sgcf_the_sub_field( 'quote' ); ?></blockquote>
<?php break;
endswitch; ?>
<?php endwhile; ?>
Or, using templates:
while ( sgcf_have_rows( 'page_sections' ) ) {
sgcf_the_row();
get_template_part( 'sections/' . sgcf_get_row_layout() );
}
Group (a loop with exactly one row, or read the array directly):
$address = sgcf_get_field( 'address' ); // ['street' => …, 'city' => …]
echo esc_html( $address['city'] );
if ( sgcf_have_rows( 'address' ) ) {
while ( sgcf_have_rows( 'address' ) ) {
sgcf_the_row();
echo esc_html( sgcf_get_sub_field( 'street' ) );
}
}
7.3 Writing values
| Function | Description |
|---|---|
sgcf_update_field( $selector, $value, $post_id = false ) | Saves a value, sanitized by the field type. Containers accept rows keyed by sub field name or key. |
sgcf_delete_field( $selector, $post_id = false ) | Deletes a value, including all container rows |
sgcf_update_sub_field( $selector, $value, $post_id = false ) | Inside a loop, updates a sub field of the current row. Outside a loop, pass a path such as array( 'chapters', 2, 'title' ) (row numbers are 1-based). |
sgcf_add_row( $selector, $row, $post_id = false ) | Appends a row and returns the new row count, or false. For flexible content, include 'acf_fc_layout' => 'name'. |
sgcf_update_row( $selector, $i, $row, $post_id = false ) | Merges values into row $i (1-based) |
sgcf_delete_row( $selector, $i, $post_id = false ) | Removes row $i (1-based) |
sgcf_update_field( 'isbn', '978-0-00-000000-0', $post_id );
sgcf_update_field( 'chapters', array(
array( 'title' => 'Prologue', 'pages' => 12 ),
array( 'title' => 'Chapter One', 'pages' => 30 ),
), $post_id );
sgcf_add_row( 'chapters', array( 'title' => 'Epilogue', 'pages' => 8 ), $post_id );
sgcf_update_row( 'chapters', 2, array( 'pages' => 32 ), $post_id );
sgcf_delete_row( 'chapters', 1, $post_id );
sgcf_add_row( 'page_sections', array( 'acf_fc_layout' => 'quote', 'quote' => 'Hello' ), $post_id );
7.4 Users, terms, comments and menus
// Term fields on a category archive.
$term = get_queried_object();
$color = sgcf_get_field( 'genre_color', $term ); // WP_Term object
$icon = sgcf_get_field( 'genre_icon', 'genre_' . $term->term_id ); // "{taxonomy}_{id}"
$same = sgcf_get_field( 'genre_icon', 'term_' . $term->term_id ); // "term_{id}"
// User fields (e.g. author archive).
$author_id = get_the_author_meta( 'ID' );
echo esc_html( sgcf_get_field( 'twitter_handle', 'user_' . $author_id ) );
// Loop through a repeater on a user.
while ( sgcf_have_rows( 'awards', 'user_' . $author_id ) ) {
sgcf_the_row();
echo esc_html( sgcf_get_sub_field( 'award_name' ) );
}
// Comment and menu item fields.
$rating = sgcf_get_field( 'rating', 'comment_' . $comment->comment_ID );
$badge = sgcf_get_field( 'menu_badge', $menu_item ); // in a nav walker, $menu_item is a WP_Post
8. Registering definitions in PHP
Register definitions on the sgcf/init action. It runs on init priority 4, before the plugin registers post types and taxonomies. Definitions registered in code appear in the admin with a "PHP" badge and are read-only there.
add_action( 'sgcf/init', function () {
sgcf_register_post_type( array(
'key' => 'post_type_book',
'title' => 'Books',
'post_type' => 'book',
'labels' => array( 'name' => 'Books', 'singular_name' => 'Book' ),
'menu_icon' => 'dashicons-book',
'supports' => array( 'title', 'editor', 'thumbnail' ),
'has_archive' => true,
) );
sgcf_register_taxonomy( array(
'key' => 'taxonomy_genre',
'title' => 'Genres',
'taxonomy' => 'genre',
'object_type' => array( 'book' ),
'hierarchical'=> true,
) );
sgcf_add_options_page( array(
'page_title' => 'Store Settings',
'menu_slug' => 'store-settings',
) );
sgcf_add_options_sub_page( array( 'page_title' => 'Footer' ) ); // under the last top-level page
sgcf_add_local_field_group( array(
'key' => 'group_book_details',
'title' => 'Book Details',
'fields' => array(
array( 'key' => 'field_book_subtitle', 'label' => 'Subtitle', 'name' => 'subtitle', 'type' => 'text' ),
array(
'key' => 'field_book_chapters', 'label' => 'Chapters', 'name' => 'chapters', 'type' => 'repeater',
'sub_fields' => array(
array( 'key' => 'field_book_ch_title', 'label' => 'Title', 'name' => 'title', 'type' => 'text' ),
),
),
),
'location' => array( array( array( 'param' => 'post_type', 'operator' => '==', 'value' => 'book' ) ) ),
) );
} );
Notes:
sgcf_add_options_page()andsgcf_add_options_sub_page()also accept a plain page title string. Their arguments match ACF's.- The Tools > Export > Generate PHP button writes this code for you.
- When ACF compatibility is on, ACF code registered on
acf/initoracf/include_fieldsalso works (see section 10).
9. Front-end forms
sgcf_form() renders field groups on the front end. It works like acf_form(): it can edit an existing post, term or user, or create a new post. Submissions are signed and nonce-checked, include a honeypot field, and are processed automatically on template_redirect. If you prefer, call sgcf_form_head() before get_header().
<?php sgcf_form_head(); get_header(); ?>
<?php
sgcf_form( array(
'post_id' => 'new_post',
'new_post' => array( 'post_type' => 'testimonial', 'post_status' => 'pending' ),
'field_groups' => array( 'group_testimonial' ),
'post_title' => true,
'submit_value' => 'Send testimonial',
'updated_message' => 'Thanks! Your testimonial is awaiting review.',
) );
?>
| Argument | Default |
|---|---|
id | 'sgcf-form' |
post_id | the current object, or 'new_post' |
new_post | false (or an array of post data) |
field_groups | array() |
fields | array() |
post_title | false |
post_content | false |
form | true |
form_attributes | array() |
return | '' |
html_before_fields | '' |
html_after_fields | '' |
submit_value | 'Update' |
updated_message | 'Post updated' |
label_placement | 'top' |
instruction_placement | 'label' |
field_el | 'div' |
uploader | 'wp' |
honeypot | true |
html_updated_message | (markup) |
html_submit_button | (markup) |
html_submit_spinner | (markup) |
kses | true |
Who can submit. By default any visitor can submit a form you place on a page. To restrict it, use the sgcf/front_end_form/can_submit filter, for example to require login.
10. ACF compatibility and migration
10.1 What is compatible
Data format. Field values use ACF's storage format:
| Field type | Storage |
|---|---|
| Any field | {name} holds the value and _{name} holds the field key |
| Repeater | Row count in {name}, rows in {name}_{i}_{sub} |
| Flexible content | Array of layout names in {name}, rows in {name}_{i}_{sub} |
| Group | Sub values in {name}_{sub} |
| Options | options_{name} |
| Date / time | Ymd, Y-m-d H:i:s, H:i:s |
Definition format. Field group, post type, taxonomy and options page definitions use ACF's JSON shape, so ACF JSON exports import directly.
ACF-named functions. These are defined when ACF is not active and Settings > Developer > ACF-compatible functions is on (the default). A function that already exists is never redefined.
get_field,the_field,get_fields,get_field_object,get_field_objectsupdate_field,delete_fieldhave_rows,the_row,get_row,get_row_index,get_row_layout,reset_rowsget_sub_field,the_sub_field,get_sub_field_object,update_sub_fieldadd_row,update_row,delete_rowacf_add_local_field_group,acf_add_options_page,acf_add_options_sub_pageacf_form,acf_form_headacf_register_block_type,acf_register_block,acf_get_block_types
ACF hooks that are honoured (when ACF is not active):
acf/initandacf/include_fieldsare fired.acf/load_field, including its/type=,/name=and/key=variants, is applied to fields at runtime.acf/load_value,acf/update_value,acf/format_value(each with/type=,/name=and/key=variants) andacf/validate_value(with/type=,/name=,/key=) are applied to values. They receive ACF-style post IDs (123,user_5,term_7,option).acf/prepare_field(with variants) can change or hide a field before it is rendered, andacf/render_fieldfires after each field.acf/save_postfires after posted values are saved.acf/fields/relationship/query,acf/fields/post_object/queryandacf/fields/page_link/queryfilter the search queries of those fields.acf/settings/save_jsonandacf/settings/load_jsonare applied to Local JSON paths.
Code you wrote for ACF that hooks into these keeps working without changes.
Everything else:
- The
shortcode. - The REST
acfproperty, withacf_format=standard. - block.json blocks with an
"acf"key.
10.2 Migrating from ACF / ACF Pro
- Back up the database.
- In ACF, go to ACF > Tools > Export and export all field groups, post types, taxonomies and options pages as JSON.
- In Sysgage Custom Fields, go to Custom Fields > Tools > Import and upload the file. Keys are kept, so your stored values connect to the imported fields straight away.
- Deactivate ACF. Your templates now use the plugin's ACF-compatible functions.
- Check your front-end templates and edit screens, ideally on a staging copy first.
- Optional: switch your templates to the
sgcf_functions. Then you can turn off the ACF aliases.
If your field groups were registered in PHP with acf_add_local_field_group() on acf/init, they keep working with no changes. If they live in an acf-json folder, add that folder with the acf/settings/load_json filter, or import the files.
If ACF itself does not load (for example the code that registers your options pages), see section 8 for registering them in code.
10.3 Migrating from CPT UI
- In CPT UI, go to Tools and copy or download the post types and/or taxonomies JSON. The combined export also works.
- In Sysgage Custom Fields, go to Custom Fields > Tools > Import. Tick Import as inactive if you want to review the definitions before switching over.
- Deactivate CPT UI, then activate the imported definitions. The slugs are the same, so existing posts and terms appear unchanged.
10.4 Differences from ACF
- ACF hooks. The common hooks listed in 10.1 are bridged. Less common ones (for example
acf/input/admin_headoracf/fields/flexible_content/layout_title) are not fired under the ACF name. Most have ansgcf/equivalent (see section 17). - Text fields keep simple HTML like ACF does. Line breaks are removed, and users without the
unfiltered_htmlcapability are limited to the tags allowed in post content. - No direct database import. There is no one-click importer that reads ACF's database tables. Migrate with ACF's JSON export, as described in 10.2.
10.5 Running next to Sysgage Content Types or ACF
With Sysgage Content Types. Both plugins can be active at the same time. Each keeps its own definitions, settings and admin menu, and fields from both appear side by side on edit screens. The ACF-named functions (get_field(), have_rows() and the rest), the shortcode, the REST acf property and the ACF hook bridge are provided once and shared: a call is sent to whichever plugin owns the field you ask for. get_fields() merges the fields from both. Nested row loops work across the two plugins. The Overview screen shows "Shared with Sysgage Content Types" next to the ACF functions.
Tips:
- Avoid giving fields from both plugins the same name on the same object. When it happens, Sysgage Custom Fields wins.
- Each plugin keeps its own Local JSON folder (
sgcf-jsonandsgct-json).
With ACF or ACF PRO. When ACF is active, the ACF-named functions, the shortcode, the REST acf property and the ACF hooks belong to ACF. Sysgage Custom Fields stands down for those names, and its sgcf_ functions keep working.
11. REST API
Turn it on or off under Settings > Integrations > REST API (on by default).
11.1 Field values on core endpoints
Field values appear on posts and custom post types, terms, users and comments (any type that is shown in REST):
- under the
sgcfproperty - under
acfas well, when ACF is not active and ACF compatibility is on
Only these fields are included:
- fields in groups with Show in REST API turned on
- fields that have their own
show_in_restsetting on (the default) - never password fields, or fields that store no value (messages, tabs, accordions)
GET /wp-json/wp/v2/book/42
{ …, "sgcf": { "subtitle": "A Novel", "cover_image": 118, "chapters": [ { "title": "Prologue", "pages": 12 } ] } }
Formats:
- Default ("light"): IDs for attachments and related posts, terms and users, typed scalars, and containers keyed by sub field name. Flexible content rows include
acf_fc_layout. ?sgcf_format=standard(oracf_format=standard): the same values assgcf_get_field(), such as image arrays and formatted dates.
Who can read:
| Object | Rule |
|---|---|
| Password-protected post | Only users who can edit it, or requests that send the right password |
| User | Users who can edit that user, or list_users |
| Comment | Users who can edit it |
Filter: sgcf/rest/can_read.
Updating:
POST /wp-json/wp/v2/book/42
{ "sgcf": { "subtitle": "Second Edition", "chapters": [ { "title": "Intro", "pages": 4 } ] } }
This needs edit_post, edit_term, edit_user or edit_comment (filter sgcf/rest/can_edit). Values are sanitized and validated like any other save.
11.2 Plugin routes (sgcf/v1)
| Route | Method | Permission | Purpose |
|---|---|---|---|
/sgcf/v1/options/{post_id} | GET | edit_posts + each matching page's capability | Values of the options pages stored under {post_id} (e.g. options). Accepts sgcf_format=light|standard. |
/sgcf/v1/options/{post_id} | POST / PUT / PATCH | same | Update values. Body: { "sgcf": { … } } or { "fields": { … } }. |
/sgcf/v1/field-groups | GET | manage_options | List field groups. Parameters: status=all|active|inactive, fields=true|false. |
/sgcf/v1/field-groups/{key} | GET | manage_options | One field group definition |
/sgcf/v1/blocks/render | POST | edit_posts / edit_post | Used by the block editor to preview field blocks |
12. Shortcode
"Uncategorised"
| Attribute | Default | Description |
|---|---|---|
field | Field name or key (required) | |
post_id | current post | Any object ID from section 7 |
format | 1 | 0 outputs the raw value |
default | '' | Shown when the value is empty or not allowed |
size | full | Image size for image and gallery fields |
separator | , | Separator between values in a list |
before / after | '' | Text around the output (escaped) |
Output by field type:
| Field type | Output |
|---|---|
| Image | <img> |
| Gallery | A row of images |
| File, link, URL | A link |
An obfuscated mailto: link | |
| True / False | Yes / No |
| WYSIWYG, text area, oEmbed | Filtered HTML |
| Color | The color value |
| Map | The address |
| Lists | Joined with separator |
Built-in protections:
- Only registered fields are shown. Arbitrary meta and
wp_optionsrows are never read, sooutputs nothing. - Selectors starting with
_are refused. - Password fields are never shown.
- Posts must be viewable by the visitor and not password-protected. Terms must belong to a public taxonomy. User fields are shown only to users who can edit that user. Comments must be approved.
- Options page values follow the rule in section 6.
The shortcode can be turned off in Settings. When ACF is not active, works the same way.
13. Blocks and block bindings
13.1 The "Custom Field Value" block (sgcf/field)
A dynamic block, in the Theme category, that displays any field. It works in posts and templates, and inside the Query Loop block: it reads the post ID from context.
| Attribute | Default | Description |
|---|---|---|
field | '' | Chosen from a searchable list of all fields |
postId | '' | Empty means the current post. Also accepts options, an options page or term_5. |
prefix / suffix | '' | Text around the value |
tagName | div | div, p, span, h1–h6, figure or section |
format | true | Format the value |
imageSize | large | Image size |
separator | , | Separator for lists |
fallback | '' | Shown when the value is empty |
linkToPost | false | Link the output to the post |
textAlign | Text alignment |
The block supports wide and full alignment, anchor, colors, spacing, typography and borders. The editor shows a live server-side preview. Access rules are the same as for the shortcode.
13.2 Block bindings (WordPress 6.5+)
The plugin registers the bindings source sgcf/field. Use it to connect core blocks to fields:
| Block | Attributes you can bind |
|---|---|
| Paragraph, Heading | content |
| Image | url, alt, id, title |
| Button | url, text, linkTarget |
Arguments: key (or field / name) and an optional post_id.
<!-- wp:heading {"metadata":{"bindings":{"content":{"source":"sgcf/field","args":{"key":"subtitle"}}}}} -->
<h2 class="wp-block-heading"></h2>
<!-- /wp:heading -->
<!-- wp:image {"metadata":{"bindings":{"url":{"source":"sgcf/field","args":{"key":"cover_image"}},"alt":{"source":"sgcf/field","args":{"key":"cover_image"}}}}} -->
<figure class="wp-block-image"><img alt=""/></figure>
<!-- /wp:image -->
<!-- wp:paragraph {"metadata":{"bindings":{"content":{"source":"sgcf/field","args":{"key":"company_phone","post_id":"options"}}}}} -->
<p></p>
<!-- /wp:paragraph -->
Image and link fields fill the matching attribute (url, alt, id, title or target). Other values become text.
Picking a field in the editor. You do not need to write the markup above by hand. Select a Paragraph, Heading, Image or Button block, open the Attributes panel in the block sidebar, choose an attribute, then pick Sysgage Custom Fields and the field. The list shows the fields that apply to the post type you are editing, and options page fields. The editor shows the field's current value as a preview. Bound attributes are read-only in the editor: edit the value in the field's meta box.
You can turn this off with Settings > Integrations > Block bindings. Filter the values with sgcf/blocks/binding_value.
13.3 Field blocks (acf_register_block_type() compatible)
You can build your own blocks whose content is stored in custom fields:
add_action( 'sgcf/init', function () {
sgcf_register_block_type( array(
'name' => 'testimonial', // becomes sgcf/testimonial
'title' => 'Testimonial',
'category' => 'text',
'icon' => 'format-quote',
'mode' => 'preview', // preview | edit | auto
'render_template' => 'blocks/testimonial.php', // relative to the child/parent theme, or absolute
'supports' => array( 'align' => true ),
) );
} );
Then create a field group with the location rule Block == sgcf/testimonial. In the template, sgcf_get_field( 'quote' ) reads the block's own values. The template has these variables: $block, $content, $is_preview, $post_id, $wp_block and $context. You can pass a render_callback instead of a template.
Other ways to register:
block.jsonwith an"sgcf"or"acf"key, for example{ "acf": { "mode": "preview", "renderTemplate": "template.php" } }.- When ACF is not active,
acf_register_block_type()registersacf/{name}blocks.
14. Local JSON
Local JSON saves every post type, taxonomy, field group and options page as a {key}.json file. This lets you keep definitions in version control and deploy them between environments.
- Turn it on: create a folder named
sgcf-jsonin your active theme. As with ACF, the folder must exist; the plugin does not create it (filtersgcf/local_json/auto_create). You can also pick another folder under Settings > Developer > JSON folder: an absolute path, or one relative to the WordPress root. It must be insidewp-contentor a theme folder. - Saving: each save writes the file. Deleting a definition deletes its file.
- Loading: files whose definitions are not in the database are still loaded and work as normal, with a "Local JSON" badge. A child theme also loads its parent theme's
sgcf-jsonfolder. - Sync: when a file is newer than the database copy, or is not in the database at all, it shows up under Tools > Local JSON Sync and as a "Sync available" badge. You can also sync from the command line with
wp sgcf sync. - Multisite: only network admins can write files.
Filters: sgcf/local_json/path, sgcf/local_json/load_paths, sgcf/local_json/enabled, sgcf/local_json/save_data, sgcf/local_json/allowed_roots. When ACF is not active, acf/settings/save_json and acf/settings/load_json are also applied.
15. WP-CLI
wp sgcf list <post_type|taxonomy|field_group|options_page> [--status=all|active|inactive] [--fields=<cols>] [--format=table|json|csv|yaml|count|ids]
wp sgcf export [--type=<type>] [--keys=<k1,k2>] [--file=<path>] [--php] [--text-domain=<domain>]
wp sgcf import <file|-> [--conflict=skip|overwrite|duplicate] [--inactive] [--format=table|json|csv|yaml]
wp sgcf sync [--key=<key>] [--dry-run]
wp sgcf flush [--hard]
Examples:
wp sgcf list field_group --format=json
wp sgcf export --file=sgcf-export.json
wp sgcf export --php --text-domain=my-theme --file=sgcf-definitions.php
wp sgcf import acf-export-2026-01-01.json
wp sgcf import cptui-post-types.json --conflict=duplicate --inactive
wp sgcf sync --dry-run
wp sgcf flush --hard
importaccepts Sysgage, ACF / ACF Pro and CPT UI files.flushclears the definition caches and the rewrite rules. With--hard, it also rewrites.htaccess.
16. Settings
Custom Fields > Settings stores every setting in the sgcf_settings option. In code, read them with sgcf_get_setting( $name ), write them with sgcf_update_setting( $name, $value ), and filter them with sgcf/settings.
| Section | Setting | Key | Default |
|---|---|---|---|
| General | Show the Custom Fields menu | show_admin | on |
| General | Default image return format | default_return_format_image | array |
| Developer | Local JSON | local_json | on |
| Developer | JSON folder | json_path | '' (the theme's sgcf-json folder) |
| Developer | ACF-compatible functions | acf_compat_functions | on |
| Integrations | REST API | rest_enabled | on |
| Integrations | Shortcode | shortcode_enabled | on |
| Integrations | Block bindings | enable_block_bindings | on |
| Integrations | Public options pages | public_options_pages | none |
| Integrations | Google Maps API key | google_maps_api_key | '' |
| Danger zone | Delete data on uninstall | delete_data_on_uninstall | off |
Notes:
- Show the Custom Fields menu. When this is off, the menu is hidden, but your post types, taxonomies and fields keep working. The Settings screen stays available at
admin.php?page=sgcf-settings. - Delete data on uninstall. When this is on, deleting the plugin removes the definitions, the
sgcf_*options and the plugin's transients, on every site of a multisite network. Posts, terms and field values are never deleted.
17. Hooks reference
All hooks use the sgcf/ prefix. Dynamic parts are shown in {braces}.
17.1 Lifecycle
| Hook | Type | Arguments | Description |
|---|---|---|---|
sgcf/loaded | action | All modules are loaded | |
sgcf/init | action | init priority 4. Register definitions here. | |
sgcf/registered | action | $registered | Post types and taxonomies are registered (['post_type'=>[slug=>key], 'taxonomy'=>[…]]) |
sgcf/flushed_rewrite_rules | action | The plugin flushed rewrite rules | |
sgcf/upgraded | action | $from, $to | The plugin version changed |
sgcf/register_field_types | action | Register custom field types | |
sgcf/block_types_registered | action | Queued field block types are registered |
17.2 Definitions (store)
| Hook | Type | Arguments | Description |
|---|---|---|---|
sgcf/store/defaults | filter | $defaults, $type | Default definition for a store type |
sgcf/load_definition | filter | $def, $type | Every definition as it loads |
sgcf/pre_save | filter | $data, $type | A definition before validation and saving |
sgcf/validate | filter | $errors (WP_Error), $def, $type, $existing | Add validation errors |
sgcf/reserved_names | filter | $names, $type | Reserved post type and taxonomy names |
sgcf/store/can_set_code | filter | $can | Whether the user may save callbacks and controller classes |
sgcf/saved, sgcf/saved/{type} | action | $type, $saved / $saved | After a save |
sgcf/deleted, sgcf/deleted/{type} | action | $type, $def / $def | After a delete |
sgcf/duplicated | action | $type, $result, $original | After a duplicate |
sgcf/register_local | action | $type, $def | A PHP definition was registered |
sgcf/flush_cache | action | $db | The definition caches were cleared |
{type} is one of post_type, taxonomy, field_group or options_page.
17.3 Post type and taxonomy registration
| Hook | Type | Arguments | Description |
|---|---|---|---|
sgcf/register_post_type_args | filter | $args, $def | Arguments passed to register_post_type() |
sgcf/register_taxonomy_args | filter | $args, $def | Arguments passed to register_taxonomy() |
sgcf/taxonomy_object_type | filter | $object_types, $def | The post types a taxonomy is attached to |
sgcf/generate_labels | filter | $labels, $type, $singular, $plural | Automatically generated labels |
17.4 Fields and values
| Hook | Type | Arguments | Description |
|---|---|---|---|
sgcf/prepare_field | filter | $field | A field after defaults are merged in |
sgcf/load_field (+ /type={type}, /name={name}, /key={key}) | filter | $field | Runtime field definition, e.g. to fill choices dynamically |
sgcf/field_categories | filter | $cats | Type picker categories |
sgcf/builder_schema | filter | $schema | The builder's settings schema |
sgcf/sanitize_field_settings | filter | $clean, $raw | A sanitized field definition from the builder |
sgcf/parse_object_id | filter | $result, $input | How a $post_id is resolved |
sgcf/api/resolve_field | filter | $field, $selector, $oid | Which field a selector resolves to |
sgcf/load_value (+ /type=, /name=, /key=) | filter | $value, $field, $oid | A raw value after it is loaded |
sgcf/format_value (+ /type=, /name=) | filter | $value, $field, $oid | A formatted value |
sgcf/get_field | filter | $value, $selector, $oid, $field | The final sgcf_get_field() result |
sgcf/sanitize_value | filter | $clean, $value, $field | A sanitized posted value |
sgcf/update_value (+ /type=, /name=, /key=) | filter | $value, $field, $oid | A value just before it is stored |
sgcf/updated_value | action | $value, $field, $oid, $prefix | After a value is stored |
sgcf/deleted_value | action | $field, $oid, $prefix | After a value is deleted |
sgcf/validate_value (+ /type=) | filter | $result, $value, $field, $input | Return true or an error message |
sgcf/validate_posted | filter | $errors, $posted, $fields | All validation errors of a submission |
sgcf/save_post | action | $post_id | After posted values are saved (any object type) |
sgcf/options_autoload | filter | $autoload, $prefix | Autoload for option-stored values |
sgcf/attachment_array | filter | $data, $id | Image, file and gallery arrays |
sgcf/clone/fields | filter | $fields, $clone_field | The fields a clone field displays |
sgcf/icon_picker/dashicons | filter | $icons | Icons offered by the Icon Picker field |
sgcf/google_maps_api_key | filter | $key | Google Maps API key |
sgcf_the_content | filter | $html | The WYSIWYG content pipeline |
17.5 Rendering and screens
| Hook | Type | Arguments | Description |
|---|---|---|---|
sgcf/prepare_field_for_render (+ /type=, /name=, /key=) | filter | $field, $args | Change a field before it is rendered, or return false to hide it |
sgcf/field_wrapper_attributes | filter | $attrs, $field, $input_name, $args | Attributes of the field wrapper |
sgcf/render_field/before, sgcf/render_field/after | action | $field | Around each field wrapper |
sgcf/render_input/before, sgcf/render_input/after | action | $field, $value, $input_name | Around each input control |
sgcf/form_js_config / sgcf/fields_js_config | filter | $config | JavaScript config for sgcfForm / sgcfFields |
sgcf/screens/remove_wp_meta_box | filter | $remove, $post, $groups | Remove the core Custom Fields meta box |
sgcf/screens/validate_post | filter | $validate, $post | Validate this post save (drafts are skipped by default) |
sgcf/front_end_form/args | filter | $args | Front-end form arguments |
sgcf/front_end_form/can_submit | filter | $allowed, $data | Who may submit a front-end form |
sgcf/front_end_form/validate | filter | $errors, $posted, $data | Front-end validation errors |
sgcf/front_end_form/new_post | filter | $post_data, $data | Post data for a new_post form |
sgcf/front_end_form/submitted | action | $post_id, $data | After a front-end form is saved |
sgcf/front_end_form/return | filter | $url, $post_id, $data | Redirect URL after saving |
17.6 Location rules
| Hook | Type | Arguments | Description |
|---|---|---|---|
sgcf/location/rule_types | filter | $types | Add or remove rule types |
sgcf/location/rule_values, sgcf/location/rule_values/{param} | filter | $values, $param | Values offered for a rule |
sgcf/location/match/{param} | filter | $result, $rule, $screen, $group | Matching for one param |
sgcf/location/match | filter | $result, $rule, $screen, $group | Any rule's result |
sgcf/location/match_group | filter | $result, $screen, $group | Whether a whole group matches |
sgcf/location/screen | filter | $screen | Screen data before matching |
sgcf/location/screen_groups | filter | $groups, $screen | Groups shown on a screen |
sgcf/location/post_types | filter | $post_types | Post types offered in rules |
sgcf/location/post_limit, sgcf/location/term_limit | filter | $limit, $type | How many items rule selects list |
17.7 Options pages
| Hook | Type | Arguments | Description |
|---|---|---|---|
sgcf/options_pages | filter | $pages | Options pages added to the menu |
sgcf/options_page/load | action | $page, $groups | An options page loads |
sgcf/options_page/saved | action | $post_id, $page | After an options page is saved |
17.8 Integrations
| Hook | Type | Arguments | Description |
|---|---|---|---|
sgcf/rest/enabled | filter | $enabled | REST integration on or off |
sgcf/rest/acf_alias | filter | $enabled | Register the acf REST property |
sgcf/rest/fields | filter | $fields, $screen | Fields exposed for an object |
sgcf/rest/values | filter | $values, $resolved, $object_type | Values returned |
sgcf/rest/can_read, sgcf/rest/can_edit | filter | $can, $resolved[, $request] | REST access |
sgcf/rest/saved | action | $oid, $posted | After a REST update |
sgcf/shortcode/enabled | filter | $enabled | Register |
sgcf/shortcode/output | filter | $html, $value, $field, $atts | Shortcode HTML |
sgcf/shortcode/allow_access | filter | $allowed, $oid, $selector, $field | Access check for the shortcode, the block and bindings |
sgcf/shortcode/public_options_pages | filter | $slugs | Options pages that any visitor can see |
sgcf/blocks/editor_data | filter | $data | Data for the block editor script |
sgcf/blocks/field_output | filter | $html, $value, $field, $attributes | Custom Field Value block HTML |
sgcf/blocks/render_block | filter | $html, $block, $is_preview | Field block HTML |
sgcf/blocks/binding_value | filter | $result, $value, $field, $attribute, $args | Block bindings value |
sgcf/ajax/capability | filter | $cap, $action | Capability for field AJAX searches |
sgcf/ajax/query_posts_args, sgcf/fields/{type}/query | filter | $args, $field | Post search query for relational fields |
sgcf/ajax/query_terms_args, sgcf/ajax/query_users_args | filter | $args, $field | Term and user searches |
17.9 Local JSON, import and tools
| Hook | Type | Arguments | Description |
|---|---|---|---|
sgcf/local_json/enabled | filter | $enabled | Local JSON on or off |
sgcf/local_json/path | filter | $path | Save folder |
sgcf/local_json/load_paths | filter | $paths | Folders to load from |
sgcf/local_json/allowed_roots | filter | $roots | Where JSON folders may be |
sgcf/local_json/auto_create | filter | $create, $path | Create a missing folder |
sgcf/local_json/can_write | filter | $can | Who may write files |
sgcf/local_json/save_data | filter | $data, $type | File contents |
sgcf/local_json/acf_filters | filter | $enabled | Apply the acf/settings/*_json filters |
sgcf/local_json/sync_items | filter | $items | Items awaiting sync |
sgcf/local_json/synced | action | $type, $result, $path | After a file is synced |
sgcf/imported | action | $results, $conflict | After an import |
sgcf/tools/orphans | filter | $orphans | Orphaned references found by the cleanup tool |
sgcf/tools/field_reference_exists | filter | $exists, $ref | Mark a reference as still in use |
sgcf/tools/orphans_deleted | action | $removed, $delete_values | After cleanup |
17.10 Admin and settings
| Hook | Type | Arguments | Description |
|---|---|---|---|
sgcf/settings | filter | $settings | All settings |
sgcf/admin/capability | filter | $capability | Capability for the admin screens (default manage_options) |
sgcf/admin/pages | filter | $pages | Admin pages and tabs |
sgcf/admin/menu_icon | filter | $icon | Top-level menu icon |
sgcf/admin/notices | filter | $messages | Admin notice messages |
sgcf/admin/js_data / sgcf/builder/js_data | filter | $data | Admin and builder script data |
sgcf/builder/terms_limit | filter | $limit, $taxonomy | Terms listed in the builder |
sgcf/admin/before_save | filter | $data, $type, $raw, $extra | Definition posted from an editor |
sgcf/admin/saved | action | $result, $type, $extra, $is_new | After an editor save |
sgcf/admin/post_type_presets, sgcf/admin/taxonomy_presets | filter | $presets | "Add new" presets |
sgcf/admin/taxonomy_object_types | filter | $choices | Post types offered in the taxonomy editor |
sgcf/admin/parent_menu_choices | filter | $choices | Parent menus offered in the editors |
sgcf/admin/dashicons | filter | $icons | Icons in the Dashicon picker |
sgcf/admin/snippets | filter | $snippets | Dashboard cheat sheet snippets |
sgcf/admin/system_status | filter | $rows | Dashboard system status rows |
sgcf/admin/settings_sections | filter | $sections | Settings screen sections |
sgcf/admin/save_settings | filter | $new, $before | Settings before they are saved |
sgcf/settings_saved | action | $after, $before | After settings are saved |
17.11 ACF compatibility switches
| Hook | Type | Arguments | Description |
|---|---|---|---|
sgcf/acf_compat_functions | filter | $enabled | Define the ACF-named functions |
sgcf/acf_hooks | filter | $enabled | Fire the ACF-named hooks listed in 10.1 |
sgcf/acf_hooks/forward | filter | $forward | Return false to stop forwarding to the ACF-named hooks while keeping the ACF functions |
17.12 Bidirectional relationships and live location
| Hook | Type | Arguments | Description |
|---|---|---|---|
sgcf/field_type_settings | filter | $settings, $type | Extra builder settings for a field type (used to add the bidirectional settings) |
sgcf/bidirectional/can_update | filter | $allowed, $object_id | Whether a linked object may be updated (default: the current user can edit it) |
sgcf/bidirectional/synced | action | $field, $added, $removed, $object_id | After the other side of a bidirectional field is updated |
sgcf/screens/live_location | filter | $enabled, $post | Return false to turn off live showing and hiding of field groups as the template, categories, format or parent change |
Example: fill a Select field's choices dynamically
add_filter( 'sgcf/load_field/name=store_location', function ( $field ) {
$field['choices'] = array();
foreach ( get_posts( array( 'post_type' => 'store', 'numberposts' => -1 ) ) as $store ) {
$field['choices'][ $store->ID ] = $store->post_title;
}
return $field;
} );
18. Data storage
| What | Where |
|---|---|
| Post type definitions | Private posts of type sgcf-post-type (JSON in post_content, the key in post_name, status publish = active, draft = inactive) |
| Taxonomy definitions | sgcf-taxonomy |
| Field group definitions | sgcf-field-group |
| Options page definitions | sgcf-options-page |
| Field values | Post, term, user and comment meta: {name} with its key reference in _{name}. Options use {post_id}_{name} in wp_options. |
| Flexible content row labels and disabled rows | _{name}_layout_meta next to the field value (an array keyed by row index) |
| Settings | The sgcf_settings option |
| Local JSON | {key}.json in the JSON folder |
Key prefixes:
| Definition | Prefix |
|---|---|
| Post type | post_type_ |
| Taxonomy | taxonomy_ |
| Field group | group_ |
| Field | field_ |
| Layout | layout_ |
| Options page | ui_options_page_ |
19. FAQ and known limitations
Do I need ACF? No. The plugin works on its own and contains no ACF code.
Can ACF stay active? Yes. The ACF-named functions, the shortcode and the REST acf property are then ACF's, and the plugin's sgcf_ versions stay available. Avoid giving fields from both plugins the same name on the same object.
Does it work with the classic editor? Yes. It also works with the block editor, Full Site Editing templates (through the block and block bindings) and the Query Loop block.
Is it multisite-ready? Definitions are stored per site, and uninstall cleans up every site. Local JSON writes are limited to network admins. On multisite, code fields (meta box callbacks and REST controllers) can only be edited by super admins.
How do I translate it? The text domain is sysgage-custom-fields and the folder is /languages. Labels you enter for post types, taxonomies and fields are stored as you typed them. To get translatable labels, use Generate PHP with a text domain (wp sgcf export --php --text-domain=…).
Known limitations in 1.0.0:
- Live location matching covers the page template, categories and other taxonomies, post format, parent page and post status. Other rules are matched on save and reload.
- Bound block attributes are read-only in the editor.
- On multisite, user fields that are filled in on the sign-up form are not kept for pending (unactivated) sign-ups.
- Fields on the block-based widgets screen have not been confirmed. They work on the classic widgets screen.
