Skip to content
  • LocationSan Pedro, Laguna, Philippines
  • Office hoursMon–Fri, 8:00 AM – 5:00 PM PHT (UTC+8)

Features

Sysgage Custom FieldsVersion 1.0.0Updated November 26, 2026

1. Overview

AreaWhat you get
Post typesEvery register_post_type() argument in seven tabs. Labels fill in automatically, there's a Dashicon picker, a live menu preview and seven presets.
TaxonomiesEvery register_taxonomy() argument in seven tabs, including the default term and the meta box style.
Field groups36 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 fieldsRepeater (table, block or row layout, pagination), Flexible Content (rename and disable layouts per row), Gallery, Clone.
RelationshipsBidirectional relationships between posts, users and terms.
Options pagesTop-level pages and sub pages, each with its own capability, icon, storage ID and button labels.
Where fields appearPosts, pages, custom post types, terms, users (profile, add and register forms), attachments, comments, menus, menu items, classic widgets, options pages and field blocks.
Developer APIsgcf_* template functions, optional ACF aliases, PHP registration, front-end forms.
IntegrationsREST API, shortcode, the Custom Field Value block, block bindings, ACF-style field blocks, WP-CLI.
WorkflowLocal 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.

ScreenSlugCapability
Overviewsgcfmanage_options (filter sgcf/admin/capability)
Field Groupssgcf-field-groupssame
Post Typessgcf-post-typessame
Taxonomiessgcf-taxonomiessame
Options Pagessgcf-options-pagessame
Toolssgcf-toolssame
Settingssgcf-settingssame

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/snippets filter.

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.

PresetWhat it sets up
BlankNothing, start from scratch
PortfolioA portfolio post type
EventsAn events post type
TestimonialsA testimonials post type
Team MembersSupports title, editor, thumbnail and page attributes
Products / ServicesSupports title, editor, thumbnail, excerpt and page attributes
FAQSupports title, editor and page attributes

The editor has seven tabs:

TabSettings
BasicPlural 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
LabelsAll 29 WordPress labels, filled in automatically, with a "Regenerate" button
Visibility & Menushow_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 & TaxonomiesFeature cards: title, editor, author, thumbnail, excerpt, trackbacks, custom-fields, comments, revisions, page-attributes, post-formats. Taxonomy multi-select (core and custom).
URLsPermalink rewrite (post type key, custom slug or none), with front, feeds, pages, archive, archive slug, query variable
REST & PermissionsShow 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_cb and rest_controller_class fields name PHP code to run. They are read-only for users without unfiltered_html, and on multisite only super admins can edit them. You can change this with the sgcf/store/can_set_code filter.

2.3 Taxonomies

The list screen works like the post types list.

Presets: Blank, Category style and Tag style.

The editor has seven tabs:

TabSettings
BasicLabels and key (max 32 characters), the post types to attach to (all public post types, including ones you created here), public, hierarchical
LabelsAll taxonomy labels, filled in automatically
VisibilityShow UI, menu, nav menus, tag cloud, quick edit, admin column
URLsRewrite slug, with front, hierarchical URLs, query variable
REST & PermissionsREST settings, the four term capabilities, sort
Default TermEnable, name, slug, description
Meta BoxDefault, 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:

TabSettings
GeneralPage title, menu title, menu slug, description
MenuParent: 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 & Buttonspost_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

TabPurpose
ExportPick 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.
ImportUpload 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 SyncLists JSON files that are newer than the database copy, or not in the database at all. Review shows the definition; Sync imports it.
Database CleanupFinds 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

SettingKeyDefault
Labellabel''
Name (meta key)name''
Keykeyfield_… (generated)
Typetypetext
Instructionsinstructions''
Requiredrequiredfalse
Conditional logicconditional_logicfalse
Wrapper width % / class / idwrapper{width:'', class:'', id:''}
Default valuedefault_value''
Show in RESTshow_in_resttrue
Read onlyreadonlyfalse
Bidirectional (Relationship, Post Object, User, Taxonomy; Advanced tab)bidirectional, bidirectional_targetfalse, []

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

TypeType-specific settings (defaults)sgcf_get_field() returns
Text textplaceholder, prepend, append, maxlengthString. 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 textareaplaceholder, 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 numbermin, max, step, placeholder, prepend, appendint or float; '' when empty
Range rangemin, max, step, prepend, appendint or float; '' when empty
Email emailplaceholder, prepend, appendString
URL urlplaceholderString
Password passwordplaceholder, prepend, appendString. Never exposed through REST, the shortcode, the block or bindings.

3.3 Content

TypeSettings (defaults)Returns
Image imagereturn_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_typesarray: attachment array (see below). url: string. id: int. false when empty.
File filereturn_format (array), library, min_size, max_size, mime_typesSame as Image (no sizes, width or height for non-images)
WYSIWYG Editor wysiwygtabs (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 oembedwidth, heightEmbed HTML, or the URL if it can't be embedded
Gallery galleryreturn_format (array), library, insert (append | prepend), preview_size, min, max, the same size, dimension and MIME limits as ImageArray of attachment arrays, URLs or IDs; false when empty

Attachment array keys:

  • ID, id, title, filename, filesize, url, link, alt
  • author, description, caption, name, status, uploaded_to
  • date, modified, menu_order
  • mime_type, type, subtype, icon
  • images only: width, height, and sizes, which holds {size}, {size}-width and {size}-height for each size

Filter the array with sgcf/attachment_array.

3.4 Choice

choices are entered one per line as value : label.

TypeSettings (defaults)Returns
Select selectchoices, default_value, return_format (value | label | array), allow_null, multiple, ui (searchable select), placeholderSingle: value, label, or ['value'=>…, 'label'=>…]. Multiple: an array of these.
Checkbox checkboxchoices, 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 radiochoices, default_value, return_format, allow_null, other_choice, layoutValue, label or value/label array
Button Group button_groupchoices, default_value, return_format, allow_null, layout (horizontal)Same as Radio
True / False true_falsedefault_value (0), message, ui (switch, default on), ui_on_text, ui_off_textbool

3.5 Relational

TypeSettings (defaults)Returns
Link linkreturn_format (array | url)['title'=>…, 'url'=>…, 'target'=>…] or a URL; false when empty
Post Object post_objectpost_type[], post_status[], taxonomy[] (taxonomy:slug filters), return_format (object | id), allow_null, multipleWP_Post or int; an array of them when multiple; false when empty. Trashed posts are skipped.
Page Link page_linkpost_type[], post_status[], taxonomy[], allow_archives (1), allow_null, multiplePermalink string (or array of strings); archive URLs are returned as they are
Relationship relationshippost_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 taxonomytaxonomy (category), field_type (checkbox | multi_select | radio | select), return_format (id | object), allow_null, add_term (1), save_terms, load_termsCheckbox / multi select: array of IDs or WP_Term. Radio / select: one ID or WP_Term. false when empty.
User userrole[], return_format (array | object | id), allow_null, multiplearray: 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

TypeSettings (defaults)Stored asReturns
Google Map google_mapcenter_lat (-37.81411), center_lng (144.96328), zoom (14), height (400)ArrayArray 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_pickerdisplay_format (d/m/Y), return_format (d/m/Y), first_day (1)YmdDate string in return_format (site timezone)
Date Time Picker date_time_pickerdisplay_format, return_format (d/m/Y g:i a)Y-m-d H:i:sFormatted string
Time Picker time_pickerdisplay_format, return_format (g:i a)H:i:sFormatted string
Color Picker color_pickerenable_opacity, return_format (string | array)Hex or rgba()String, or ['red','green','blue','alpha']
Icon Picker icon_pickertabs (dashicons, url), return_format (string | array){type, value}dashicons-… or the URL; or ['type'=>'dashicons'|'url', 'value'=>…]

3.7 Layout

TypeSettingsReturns
Message messagemessage, new_lines, esc_htmlNo value (display only)
Accordion accordionopen, multi_expand, endpointNo value
Tab tabplacement (top | left), selected (open by default), endpoint (start a new tab group)No value
Group grouplayout (block | table | row), sub_fieldsArray of sub field values keyed by sub field name
Repeater repeatersub_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_contentlayouts (each with name, label, display, min, max, sub_fields), min, max, button_labelList of rows, each with acf_fc_layout and sgcf_layout (the layout name) plus sub values by name; false when empty
Clone cloneclone (field keys and/or group keys), display (seamless | group), layout, prefix_label, prefix_nameArray 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/synced fires 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).

ParamGroupValues
post_typePostAny post type that has a UI
post_templatePostTheme templates for posts, grouped by post type
post_statusPostpublish, future, draft, pending, private
post_formatPoststandard, aside, chat, gallery, link, image, quote, status, video, audio
post_categoryPostCategory terms
post_taxonomyPostAny term, as taxonomy:slug
postPostA specific post
page_templatePagePage templates
page_typePagefront_page, posts_page, top_level, parent, child
page_parentPageA specific parent page
pagePageA specific page
current_userUserlogged_in, viewing_front, viewing_back
current_user_roleUserRoles
user_formUserall, add, edit (Add / Edit), register
user_roleUserRole of the user being edited
taxonomyFormsTerm add/edit screens of a taxonomy, or all
attachmentFormsAll, or a MIME type or group
commentFormsAll, or comments on a post type
widgetFormsAll, or a widget ID base
nav_menuFormsAll, or a menu or menu location
nav_menu_itemFormsAll, or the items of a menu
options_pageFormsAn options page's menu slug
blockFormsA 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.

OperatorMeaning
== / !=Value is (or is not) equal. For multi-value fields: the list contains (or does not contain) the value.
==empty / !=emptyHas no value / has any value
==contains / !=containsValue contains (or does not contain) the text
==patternValue 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.

  1. Create the page under Custom Fields > Options Pages, or in code (see section 8).
  2. Create a field group with the location rule Options Page == {menu slug}.
  3. Read the values with 'options', or with the page's custom post_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_slug
  • parent_slug: empty means a top-level page. Otherwise use a menu file such as options-general.php or another page's slug.
  • capability (default edit_posts)
  • position, icon_url
  • redirect: a top-level page opens its first sub page
  • post_id (default options)
  • autoload (default false)
  • 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:

ValueObject
false / 0 / omittedThe current post in the loop, or the queried object
123 or a WP_PostA post
'term_5', '{taxonomy}_5' (e.g. 'category_5') or a WP_TermA term
'user_2' or a WP_UserA user
'comment_3' or a WP_CommentA comment
'options' or a custom options post_idAn options page
'menu_7', 'nav_menu_item_9'A menu or a menu item

7.1 Reading values

FunctionDescription
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

FunctionDescription
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

FunctionDescription
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() and sgcf_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/init or acf/include_fields also 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.',
) );
?>
ArgumentDefault
id'sgcf-form'
post_idthe current object, or 'new_post'
new_postfalse (or an array of post data)
field_groupsarray()
fieldsarray()
post_titlefalse
post_contentfalse
formtrue
form_attributesarray()
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'
honeypottrue
html_updated_message(markup)
html_submit_button(markup)
html_submit_spinner(markup)
ksestrue

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 typeStorage
Any field{name} holds the value and _{name} holds the field key
RepeaterRow count in {name}, rows in {name}_{i}_{sub}
Flexible contentArray of layout names in {name}, rows in {name}_{i}_{sub}
GroupSub values in {name}_{sub}
Optionsoptions_{name}
Date / timeYmd, 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_objects
  • update_field, delete_field
  • have_rows, the_row, get_row, get_row_index, get_row_layout, reset_rows
  • get_sub_field, the_sub_field, get_sub_field_object, update_sub_field
  • add_row, update_row, delete_row
  • acf_add_local_field_group, acf_add_options_page, acf_add_options_sub_page
  • acf_form, acf_form_head
  • acf_register_block_type, acf_register_block, acf_get_block_types

ACF hooks that are honoured (when ACF is not active):

  • acf/init and acf/include_fields are 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) and acf/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, and acf/render_field fires after each field.
  • acf/save_post fires after posted values are saved.
  • acf/fields/relationship/query, acf/fields/post_object/query and acf/fields/page_link/query filter the search queries of those fields.
  • acf/settings/save_json and acf/settings/load_json are applied to Local JSON paths.

Code you wrote for ACF that hooks into these keeps working without changes.

Everything else:

  • The shortcode.
  • The REST acf property, with acf_format=standard.
  • block.json blocks with an "acf" key.

10.2 Migrating from ACF / ACF Pro

  1. Back up the database.
  2. In ACF, go to ACF > Tools > Export and export all field groups, post types, taxonomies and options pages as JSON.
  3. 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.
  4. Deactivate ACF. Your templates now use the plugin's ACF-compatible functions.
  5. Check your front-end templates and edit screens, ideally on a staging copy first.
  6. 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

  1. In CPT UI, go to Tools and copy or download the post types and/or taxonomies JSON. The combined export also works.
  2. In Sysgage Custom Fields, go to Custom Fields > Tools > Import. Tick Import as inactive if you want to review the definitions before switching over.
  3. 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_head or acf/fields/flexible_content/layout_title) are not fired under the ACF name. Most have an sgcf/ equivalent (see section 17).
  • Text fields keep simple HTML like ACF does. Line breaks are removed, and users without the unfiltered_html capability 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-json and sgct-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 sgcf property
  • under acf as 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_rest setting 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 (or acf_format=standard): the same values as sgcf_get_field(), such as image arrays and formatted dates.

Who can read:

ObjectRule
Password-protected postOnly users who can edit it, or requests that send the right password
UserUsers who can edit that user, or list_users
CommentUsers 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)

RouteMethodPermissionPurpose
/sgcf/v1/options/{post_id}GETedit_posts + each matching page's capabilityValues of the options pages stored under {post_id} (e.g. options). Accepts sgcf_format=light|standard.
/sgcf/v1/options/{post_id}POST / PUT / PATCHsameUpdate values. Body: { "sgcf": { … } } or { "fields": { … } }.
/sgcf/v1/field-groupsGETmanage_optionsList field groups. Parameters: status=all|active|inactive, fields=true|false.
/sgcf/v1/field-groups/{key}GETmanage_optionsOne field group definition
/sgcf/v1/blocks/renderPOSTedit_posts / edit_postUsed by the block editor to preview field blocks

12. Shortcode




"Uncategorised"
AttributeDefaultDescription
fieldField name or key (required)
post_idcurrent postAny object ID from section 7
format10 outputs the raw value
default''Shown when the value is empty or not allowed
sizefullImage 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 typeOutput
Image<img>
GalleryA row of images
File, link, URLA link
EmailAn obfuscated mailto: link
True / FalseYes / No
WYSIWYG, text area, oEmbedFiltered HTML
ColorThe color value
MapThe address
ListsJoined with separator

Built-in protections:

  • Only registered fields are shown. Arbitrary meta and wp_options rows are never read, so outputs 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.

AttributeDefaultDescription
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
tagNamedivdiv, p, span, h1–h6, figure or section
formattrueFormat the value
imageSizelargeImage size
separator, Separator for lists
fallback''Shown when the value is empty
linkToPostfalseLink the output to the post
textAlignText 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:

BlockAttributes you can bind
Paragraph, Headingcontent
Imageurl, alt, id, title
Buttonurl, 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.json with an "sgcf" or "acf" key, for example { "acf": { "mode": "preview", "renderTemplate": "template.php" } }.
  • When ACF is not active, acf_register_block_type() registers acf/{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-json in your active theme. As with ACF, the folder must exist; the plugin does not create it (filter sgcf/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 inside wp-content or 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-json folder.
  • 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
  • import accepts Sysgage, ACF / ACF Pro and CPT UI files.
  • flush clears 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.

SectionSettingKeyDefault
GeneralShow the Custom Fields menushow_adminon
GeneralDefault image return formatdefault_return_format_imagearray
DeveloperLocal JSONlocal_jsonon
DeveloperJSON folderjson_path'' (the theme's sgcf-json folder)
DeveloperACF-compatible functionsacf_compat_functionson
IntegrationsREST APIrest_enabledon
IntegrationsShortcodeshortcode_enabledon
IntegrationsBlock bindingsenable_block_bindingson
IntegrationsPublic options pagespublic_options_pagesnone
IntegrationsGoogle Maps API keygoogle_maps_api_key''
Danger zoneDelete data on uninstalldelete_data_on_uninstalloff

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

HookTypeArgumentsDescription
sgcf/loadedactionAll modules are loaded
sgcf/initactioninit priority 4. Register definitions here.
sgcf/registeredaction$registeredPost types and taxonomies are registered (['post_type'=>[slug=>key], 'taxonomy'=>[…]])
sgcf/flushed_rewrite_rulesactionThe plugin flushed rewrite rules
sgcf/upgradedaction$from, $toThe plugin version changed
sgcf/register_field_typesactionRegister custom field types
sgcf/block_types_registeredactionQueued field block types are registered

17.2 Definitions (store)

HookTypeArgumentsDescription
sgcf/store/defaultsfilter$defaults, $typeDefault definition for a store type
sgcf/load_definitionfilter$def, $typeEvery definition as it loads
sgcf/pre_savefilter$data, $typeA definition before validation and saving
sgcf/validatefilter$errors (WP_Error), $def, $type, $existingAdd validation errors
sgcf/reserved_namesfilter$names, $typeReserved post type and taxonomy names
sgcf/store/can_set_codefilter$canWhether the user may save callbacks and controller classes
sgcf/saved, sgcf/saved/{type}action$type, $saved / $savedAfter a save
sgcf/deleted, sgcf/deleted/{type}action$type, $def / $defAfter a delete
sgcf/duplicatedaction$type, $result, $originalAfter a duplicate
sgcf/register_localaction$type, $defA PHP definition was registered
sgcf/flush_cacheaction$dbThe definition caches were cleared

{type} is one of post_type, taxonomy, field_group or options_page.

17.3 Post type and taxonomy registration

HookTypeArgumentsDescription
sgcf/register_post_type_argsfilter$args, $defArguments passed to register_post_type()
sgcf/register_taxonomy_argsfilter$args, $defArguments passed to register_taxonomy()
sgcf/taxonomy_object_typefilter$object_types, $defThe post types a taxonomy is attached to
sgcf/generate_labelsfilter$labels, $type, $singular, $pluralAutomatically generated labels

17.4 Fields and values

HookTypeArgumentsDescription
sgcf/prepare_fieldfilter$fieldA field after defaults are merged in
sgcf/load_field (+ /type={type}, /name={name}, /key={key})filter$fieldRuntime field definition, e.g. to fill choices dynamically
sgcf/field_categoriesfilter$catsType picker categories
sgcf/builder_schemafilter$schemaThe builder's settings schema
sgcf/sanitize_field_settingsfilter$clean, $rawA sanitized field definition from the builder
sgcf/parse_object_idfilter$result, $inputHow a $post_id is resolved
sgcf/api/resolve_fieldfilter$field, $selector, $oidWhich field a selector resolves to
sgcf/load_value (+ /type=, /name=, /key=)filter$value, $field, $oidA raw value after it is loaded
sgcf/format_value (+ /type=, /name=)filter$value, $field, $oidA formatted value
sgcf/get_fieldfilter$value, $selector, $oid, $fieldThe final sgcf_get_field() result
sgcf/sanitize_valuefilter$clean, $value, $fieldA sanitized posted value
sgcf/update_value (+ /type=, /name=, /key=)filter$value, $field, $oidA value just before it is stored
sgcf/updated_valueaction$value, $field, $oid, $prefixAfter a value is stored
sgcf/deleted_valueaction$field, $oid, $prefixAfter a value is deleted
sgcf/validate_value (+ /type=)filter$result, $value, $field, $inputReturn true or an error message
sgcf/validate_postedfilter$errors, $posted, $fieldsAll validation errors of a submission
sgcf/save_postaction$post_idAfter posted values are saved (any object type)
sgcf/options_autoloadfilter$autoload, $prefixAutoload for option-stored values
sgcf/attachment_arrayfilter$data, $idImage, file and gallery arrays
sgcf/clone/fieldsfilter$fields, $clone_fieldThe fields a clone field displays
sgcf/icon_picker/dashiconsfilter$iconsIcons offered by the Icon Picker field
sgcf/google_maps_api_keyfilter$keyGoogle Maps API key
sgcf_the_contentfilter$htmlThe WYSIWYG content pipeline

17.5 Rendering and screens

HookTypeArgumentsDescription
sgcf/prepare_field_for_render (+ /type=, /name=, /key=)filter$field, $argsChange a field before it is rendered, or return false to hide it
sgcf/field_wrapper_attributesfilter$attrs, $field, $input_name, $argsAttributes of the field wrapper
sgcf/render_field/before, sgcf/render_field/afteraction$fieldAround each field wrapper
sgcf/render_input/before, sgcf/render_input/afteraction$field, $value, $input_nameAround each input control
sgcf/form_js_config / sgcf/fields_js_configfilter$configJavaScript config for sgcfForm / sgcfFields
sgcf/screens/remove_wp_meta_boxfilter$remove, $post, $groupsRemove the core Custom Fields meta box
sgcf/screens/validate_postfilter$validate, $postValidate this post save (drafts are skipped by default)
sgcf/front_end_form/argsfilter$argsFront-end form arguments
sgcf/front_end_form/can_submitfilter$allowed, $dataWho may submit a front-end form
sgcf/front_end_form/validatefilter$errors, $posted, $dataFront-end validation errors
sgcf/front_end_form/new_postfilter$post_data, $dataPost data for a new_post form
sgcf/front_end_form/submittedaction$post_id, $dataAfter a front-end form is saved
sgcf/front_end_form/returnfilter$url, $post_id, $dataRedirect URL after saving

17.6 Location rules

HookTypeArgumentsDescription
sgcf/location/rule_typesfilter$typesAdd or remove rule types
sgcf/location/rule_values, sgcf/location/rule_values/{param}filter$values, $paramValues offered for a rule
sgcf/location/match/{param}filter$result, $rule, $screen, $groupMatching for one param
sgcf/location/matchfilter$result, $rule, $screen, $groupAny rule's result
sgcf/location/match_groupfilter$result, $screen, $groupWhether a whole group matches
sgcf/location/screenfilter$screenScreen data before matching
sgcf/location/screen_groupsfilter$groups, $screenGroups shown on a screen
sgcf/location/post_typesfilter$post_typesPost types offered in rules
sgcf/location/post_limit, sgcf/location/term_limitfilter$limit, $typeHow many items rule selects list

17.7 Options pages

HookTypeArgumentsDescription
sgcf/options_pagesfilter$pagesOptions pages added to the menu
sgcf/options_page/loadaction$page, $groupsAn options page loads
sgcf/options_page/savedaction$post_id, $pageAfter an options page is saved

17.8 Integrations

HookTypeArgumentsDescription
sgcf/rest/enabledfilter$enabledREST integration on or off
sgcf/rest/acf_aliasfilter$enabledRegister the acf REST property
sgcf/rest/fieldsfilter$fields, $screenFields exposed for an object
sgcf/rest/valuesfilter$values, $resolved, $object_typeValues returned
sgcf/rest/can_read, sgcf/rest/can_editfilter$can, $resolved[, $request]REST access
sgcf/rest/savedaction$oid, $postedAfter a REST update
sgcf/shortcode/enabledfilter$enabledRegister
sgcf/shortcode/outputfilter$html, $value, $field, $attsShortcode HTML
sgcf/shortcode/allow_accessfilter$allowed, $oid, $selector, $fieldAccess check for the shortcode, the block and bindings
sgcf/shortcode/public_options_pagesfilter$slugsOptions pages that any visitor can see
sgcf/blocks/editor_datafilter$dataData for the block editor script
sgcf/blocks/field_outputfilter$html, $value, $field, $attributesCustom Field Value block HTML
sgcf/blocks/render_blockfilter$html, $block, $is_previewField block HTML
sgcf/blocks/binding_valuefilter$result, $value, $field, $attribute, $argsBlock bindings value
sgcf/ajax/capabilityfilter$cap, $actionCapability for field AJAX searches
sgcf/ajax/query_posts_args, sgcf/fields/{type}/queryfilter$args, $fieldPost search query for relational fields
sgcf/ajax/query_terms_args, sgcf/ajax/query_users_argsfilter$args, $fieldTerm and user searches

17.9 Local JSON, import and tools

HookTypeArgumentsDescription
sgcf/local_json/enabledfilter$enabledLocal JSON on or off
sgcf/local_json/pathfilter$pathSave folder
sgcf/local_json/load_pathsfilter$pathsFolders to load from
sgcf/local_json/allowed_rootsfilter$rootsWhere JSON folders may be
sgcf/local_json/auto_createfilter$create, $pathCreate a missing folder
sgcf/local_json/can_writefilter$canWho may write files
sgcf/local_json/save_datafilter$data, $typeFile contents
sgcf/local_json/acf_filtersfilter$enabledApply the acf/settings/*_json filters
sgcf/local_json/sync_itemsfilter$itemsItems awaiting sync
sgcf/local_json/syncedaction$type, $result, $pathAfter a file is synced
sgcf/importedaction$results, $conflictAfter an import
sgcf/tools/orphansfilter$orphansOrphaned references found by the cleanup tool
sgcf/tools/field_reference_existsfilter$exists, $refMark a reference as still in use
sgcf/tools/orphans_deletedaction$removed, $delete_valuesAfter cleanup

17.10 Admin and settings

HookTypeArgumentsDescription
sgcf/settingsfilter$settingsAll settings
sgcf/admin/capabilityfilter$capabilityCapability for the admin screens (default manage_options)
sgcf/admin/pagesfilter$pagesAdmin pages and tabs
sgcf/admin/menu_iconfilter$iconTop-level menu icon
sgcf/admin/noticesfilter$messagesAdmin notice messages
sgcf/admin/js_data / sgcf/builder/js_datafilter$dataAdmin and builder script data
sgcf/builder/terms_limitfilter$limit, $taxonomyTerms listed in the builder
sgcf/admin/before_savefilter$data, $type, $raw, $extraDefinition posted from an editor
sgcf/admin/savedaction$result, $type, $extra, $is_newAfter an editor save
sgcf/admin/post_type_presets, sgcf/admin/taxonomy_presetsfilter$presets"Add new" presets
sgcf/admin/taxonomy_object_typesfilter$choicesPost types offered in the taxonomy editor
sgcf/admin/parent_menu_choicesfilter$choicesParent menus offered in the editors
sgcf/admin/dashiconsfilter$iconsIcons in the Dashicon picker
sgcf/admin/snippetsfilter$snippetsDashboard cheat sheet snippets
sgcf/admin/system_statusfilter$rowsDashboard system status rows
sgcf/admin/settings_sectionsfilter$sectionsSettings screen sections
sgcf/admin/save_settingsfilter$new, $beforeSettings before they are saved
sgcf/settings_savedaction$after, $beforeAfter settings are saved

17.11 ACF compatibility switches

HookTypeArgumentsDescription
sgcf/acf_compat_functionsfilter$enabledDefine the ACF-named functions
sgcf/acf_hooksfilter$enabledFire the ACF-named hooks listed in 10.1
sgcf/acf_hooks/forwardfilter$forwardReturn false to stop forwarding to the ACF-named hooks while keeping the ACF functions

17.12 Bidirectional relationships and live location

HookTypeArgumentsDescription
sgcf/field_type_settingsfilter$settings, $typeExtra builder settings for a field type (used to add the bidirectional settings)
sgcf/bidirectional/can_updatefilter$allowed, $object_idWhether a linked object may be updated (default: the current user can edit it)
sgcf/bidirectional/syncedaction$field, $added, $removed, $object_idAfter the other side of a bidirectional field is updated
sgcf/screens/live_locationfilter$enabled, $postReturn 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

WhatWhere
Post type definitionsPrivate posts of type sgcf-post-type (JSON in post_content, the key in post_name, status publish = active, draft = inactive)
Taxonomy definitionssgcf-taxonomy
Field group definitionssgcf-field-group
Options page definitionssgcf-options-page
Field valuesPost, 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)
SettingsThe sgcf_settings option
Local JSON{key}.json in the JSON folder

Key prefixes:

DefinitionPrefix
Post typepost_type_
Taxonomytaxonomy_
Field groupgroup_
Fieldfield_
Layoutlayout_
Options pageui_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.