Cybo Advanced Field EngineCyboweb Technologies · Documentation · v1.0.2

Settings Pages

A Settings Page is an admin screen for site-wide content that is not tied to one post: phone numbers, social links, opening hours, footer text, a promotion banner. Editors fill it in once; your theme reads it anywhere with cafe_get_option().

CAFE → Settings Pages → New Settings Page "Contact Settings"
CAFE → Add New field group "Contact details"  →  Location: Settings Page is Contact Settings
Admin menu → Contact Settings → fill in, Save (or Ctrl + S)
Theme → cafe_get_option( 'phone' )

1. Create the page

Go to CAFE → Settings Pages and click New Settings Page.

Setting What it does
Page Title The heading, e.g. "Contact Settings".
Slug The page address (admin.php?page=contact-settings). Filled from the title; fixed after creation because field group locations use it.
Menu Title Shorter menu label (optional).
Show In Menu Its own menu item, or under Dashboard, Posts, Pages, Media, Appearance, Plugins, Users, Tools, Settings, or another top-level Settings Page. The live menu preview shows where it goes.
Menu Icon / Position For pages with their own menu item.
Who Can Edit Administrators, administrators and theme managers, editors and above, or authors and above. They see the page in the menu and can save it.
Description Text under the heading.
Save Button Custom label, e.g. "Update Contact Info".
Show Page Switch a page off without deleting it.

Each page card shows the field groups placed on it, with links to open the page or add a field group to it.

2. Add fields

Click + Field Group on the page card (or Add a Field Group for this page on the empty page). The new group's location is already set to Settings Page is Contact Settings. Every field type works, including Collections, Section Builders, galleries and the Rich Text Editor.

Group presentation settings apply:

  • Position: Side puts the group in a narrow column on the right.
  • Box color colors the card's marker and the accent inside it.
  • Label placement: Left puts labels beside the inputs.

3. Fill it in

The page shows one card per field group. When there are several groups, links at the top jump to each card. Editors get:

  • an Unsaved changes badge and a warning before leaving with unsaved changes,
  • Ctrl + S (Cmd + S on Mac) to save,
  • a clear message after saving, with the fields that could not be saved.
A Settings Page as editors see it
A Settings Page as editors see it

4. Use the values

// One value.
echo esc_html( cafe_get_option( 'phone' ) );

// With a default.
$hours = cafe_get_option( 'opening_hours', 'Mon-Fri 9:00-17:00' );

// A Collection on a Settings Page.
foreach ( cafe_rows( 'social_profiles', 'option', 'option' ) as $profile ) {
	printf(
		'<a href="%s">%s</a>',
		esc_url( $profile['url'] ),
		esc_html( $profile['network'] )
	);
}

Values are loaded with one query and cached like every other CAFE object (see Caching).

From code

add_action( 'cafe_init', function () {
	cafe_add_settings_page(
		[
			'title'       => 'Theme Options',
			'parent_menu' => 'themes.php',
			'capability'  => 'edit_theme_options',
		]
	);
} );

All options: cafe_add_settings_page().

In Elementor

Settings Page fields can be used as Elementor Dynamic Tags. They need no post, so they also work in headers, footers and archive templates, and they follow the current language. See Elementor.

Good to know

  • One site-wide scope. All Settings Pages save into the same options scope, so give option fields unique names (footer_text, not text).
  • Deleting a page keeps its values and its field groups. Create a page with the same slug and everything is back. Pages placed under a deleted page move to their own menu item.
  • Security. Saving checks a nonce for that page and the page's "Who Can Edit" capability. Only fields of groups shown on the page are saved. Managing pages (CAFE → Settings Pages) needs the CAFE capability (administrators by default).
  • An address another plugin uses. When another plugin already shows a menu page with the same slug (admin.php?page=…), the CAFE page stays out of the menu, even when it is switched on: two pages cannot answer one address. Its card in CAFE → Settings Pages says so. The page appears by itself on the next admin screen after the other page is gone. After an ACF → CAFE conversion this is ACF's own options page: see ACF → CAFE.
  • Multisite. Each site has its own Settings Pages and values.
  • Hook. cafe_settings_page_saved fires after a page is saved; see Hooks.