Composer package for managing WordPress options pages using ACF and custom post type. Data is stored and retrieved from post_content field and does not use the wp_options table. Supports multiple instances and capability-based access control.
In case you use custom capabilities make sure you create and assign capability to Administrator role otherwise options page will not be visible/accessible. You can use plugin like User Role Editor to manage custom capabilites and roles.
- PHP >= 8.1
- WordPress >= 6.0
- Advanced Custom Fields
composer require codesoup/acf-options-
Download the plugin as a ZIP file from GitHub
-
Extract the ZIP file to your WordPress plugins directory
-
Activate the plugin
-
Add required create/register_page code to your functions.php
use CodeSoup\ACFOptions\Manager;
$manager = Manager::create( 'my_instance_key' );
$manager->register_page(
array(
'id' => 'general',
'title' => 'General Settings',
'capability' => 'manage_options',
)
);
$manager->init();
// Retrieve options
$options = $manager->get_options( 'general' );// In functions.php or plugin init
$manager = \CodeSoup\ACFOptions\Manager::create( 'my_instance_key' );
$manager->register_page(
array(
'id' => 'general',
'title' => 'General Settings',
'capability' => 'manage_footer_options', // Custom wp_capability
)
);
$manager->init();
// In template file eg: header.php
$manager = \CodeSoup\ACFOptions\Manager::get( 'my_instance_key' );
$options = $manager->get_options( 'general' );Available options with defaults:
$manager = Manager::create(
'my_instance_key',
array(
'post_type' => 'codesoup_options', // {my_instance_key}_options
'prefix' => 'codesoup-', // {my_instance_key}-options-
'menu_position' => 50, // 99
'menu_icon' => 'dashicons-admin-settings', // dashicons-admin-generic
'menu_label' => 'Site Options', // ACF Options
)
);Assign field groups using the ACF Options location rule.
Static Methods
create( string $instance_key, array $config = [] ): Managerget( string $instance_key ): ?Managerget_all(): arraydestroy( string $instance_key ): bool
Instance Methods
register_page( array $args ): voidinit(): voidget_options( string $page_id ): array