18. Options Pages | Field Forge - Custom Fields, Built for Speed
Download Log in

18. Options Pages

Developer Guide

Options pages provide a UI for site-wide settings (logo, footer text, social links, etc.). Requires PRO license. Values are accessed using get_field( 'field_name', 'options' ).

Field Forge supports three registration paths — pick whichever fits your workflow. They coexist; values stored against a given slug are reachable regardless of how the page was registered.

PathSourceWhen to use
Admin UI (Field Forge > Options Pages)wp_fieldforge_options_pages tableContent managers want to add or rename pages without touching code
Auto-register from a field-group location rule (options_page == )Field group definitionThe page hosts exactly one field group; you don’t need a custom icon or position
fieldforge_add_options_page([...]) PHP APIfunctions.php / plugin codeThe registration should ship with the theme; you want full control over icon, position, capability, parent slug

fieldforge_add_options_page( $args )

Full Parameter Reference:
ParameterTypeDefaultDescription
page_titlestring'Options'Page title shown at the top
menu_titlestring'Options'Menu label in admin sidebar
menu_slugstring'fieldforge-options'Unique slug for page URL
capabilitystring'manage_options'Required capability
parent_slugstring''Parent menu slug (empty = top-level)
icon_urlstring'dashicons-admin-generic'Dashicon class or image URL
positionintnullnullMenu position

Top-Level Options Page

php
add_action( 'init', function() {
    if ( ! function_exists( 'fieldforge_add_options_page' ) ) {
        return;
    }

    fieldforge_add_options_page( [
        'page_title' => 'Theme Settings',
        'menu_title' => 'Theme Settings',
        'menu_slug'  => 'theme-settings',
        'icon_url'   => 'dashicons-admin-customizer',
        'position'   => 2,
    ] );
} );

Sub-Pages Under a Parent

php
add_action( 'init', function() {
    if ( ! function_exists( 'fieldforge_add_options_page' ) ) {
        return;
    }

    fieldforge_add_options_page( [
        'page_title' => 'Site Options',
        'menu_title' => 'Site Options',
        'menu_slug'  => 'site-options',
        'icon_url'   => 'dashicons-admin-site',
    ] );

    fieldforge_add_options_page( [
        'page_title'  => 'Header Settings',
        'menu_title'  => 'Header',
        'menu_slug'   => 'site-options-header',
        'parent_slug' => 'site-options',
    ] );

    fieldforge_add_options_page( [
        'page_title'  => 'Footer Settings',
        'menu_title'  => 'Footer',
        'menu_slug'   => 'site-options-footer',
        'parent_slug' => 'site-options',
    ] );
} );

Accessing Options Page Values

php
$logo    = get_field( 'site_logo', 'options' );
$phone   = get_field( 'site_phone', 'options' );

// Repeater on options page
if ( have_rows( 'business_hours', 'options' ) ) :
    echo '<table class="hours">';
    while ( have_rows( 'business_hours', 'options' ) ) : the_row();
        echo '<tr><td>' . esc_html( get_sub_field( 'day' ) ) . '</td>';
        echo '<td>' . esc_html( get_sub_field( 'hours' ) ) . '</td></tr>';
    endwhile;
    echo '</table>';
endif;

REST API for UI-managed pages

Pages added in the admin UI live in wp_fieldforge_options_pages and are exposed for headless / scripted management (PHP-API and field-group-rule sources are NOT in this table and are read-only via this endpoint). All routes require an authenticated request with manage_options.

text
GET    /wp-json/fieldforge/v1/options-pages          # list active rows (?include_deleted=1 to see soft-deleted)
GET    /wp-json/fieldforge/v1/options-pages/{id}     # one row
POST   /wp-json/fieldforge/v1/options-pages          # create — body: { page_title, menu_slug, capability, parent_slug, position, icon_url, ... }
PUT    /wp-json/fieldforge/v1/options-pages/{id}     # update — same body shape
DELETE /wp-json/fieldforge/v1/options-pages/{id}     # soft-delete (status='deleted')

Validation matches the admin UI: page_title and menu_slug required, slug must be unique, reserved Field Forge slugs (e.g. fieldforge-settings) are rejected. Errors return WP_Error-shaped JSON with code and message.

Lang Forge Integration

When Lang Forge is active, options page values are stored per language. From the template side, get_field() automatically returns the value for the current language.

php
// These calls automatically return the correct language value
$logo  = get_field( 'site_logo', 'options' );
$phone = get_field( 'site_phone', 'options' );
$cta   = get_field( 'cta_text', 'options' );

// Internal storage:
// Default (EN): option_page = 'site-options'
// French:       option_page = 'site-options:fr'
// Spanish:      option_page = 'site-options:es'

Forge AI Assistant Online

Hi! I'm the Field Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs