PHP registration API
Registering field groups in code#
ultivo_add_local_field_group( array $group ): void registers a field group without touching the database. Call it inside the ultivo/init action, so it runs at the same point the plugin loads its own local groups:
add_action( 'ultivo/init', function () { ultivo_add_local_field_group( [ 'key' => 'group_hero', 'title' => 'Hero', 'fields' => [ [ 'key' => 'field_hero_title', 'name' => 'hero_title', 'label' => 'Title', 'type' => 'text' ], ], 'location' => [ [ [ 'param' => 'post_type', 'operator' => '==', 'value' => 'page' ] ] ], ] ); } );
A field group registered this way behaves exactly like one built visually or synced through Local JSON: it just isn't editable from the admin. You don't have to write the array by hand: build the group in Custom Fields → Add New, then use Ultivo Toolkit → Tools → Export as PHP to generate this exact structure for a group you already have.
Options pages in code#
ultivo_add_options_page( $settings = [] ): array registers a settings page that isn't tied to any post. Passing a string is shorthand for the page title:
add_action( 'ultivo/init', function () { ultivo_add_options_page( 'Site settings' ); } );
For control over menu placement, capability or icon, pass the array form. See Options, users & terms for the full settings list and how to read values back from the resulting page.