-
Notifications
You must be signed in to change notification settings - Fork 11
acf_add_customizer_section
acf_add_customizer_section( $section = '' )
Adds a customizer section.
Call this function before or inside the init hook.
-
$section = ''
String|Array As a string: the name of the Customizer section.
Array argument values:-
title
(mandatory) String. -
storage_type
(optional) String
choose one oftheme_mod
(default),option
,post
,term
option
will save the field values in the wp options table – just like an ACF options page.
theme_mod
will save the field value as a theme mod. Useget_field( 'field_selector', $post_id )
in the frontend.
post
andterm
will save the values in the currently displayed post or term meta. -
post_id
(optional) String.
Defaults to sanitized title argument fortheme_mod
andoption
storage types.
Omit if you choosepost
orterm
storage type. -
active_callback
(optional) callable
If storage type ispost
orterm
the default is a function which returns whether the current page is a post or a term archive page.
see also https://developer.wordpress.org/reference/classes/wp_customize_manager/add_section/ -
panel
(optional) null|String.
Parent panel ID. Defaultnull
see https://developer.wordpress.org/reference/classes/wp_customize_manager/add_section/ -
capability
(optional) String. Default:'edit_theme_options'
see https://developer.wordpress.org/reference/classes/wp_customize_manager/add_section/ -
theme_supports
(optional) array
Default:array()
see https://developer.wordpress.org/reference/classes/wp_customize_manager/add_section/ -
description
(optional) String
Default:''
see https://developer.wordpress.org/reference/classes/wp_customize_manager/add_section/ -
priority
(optional) integer
Default:160
see https://developer.wordpress.org/reference/classes/wp_customize_manager/add_section/ -
description_hidden
(optional) Boolean
Default:false
see (https://developer.wordpress.org/reference/classes/wp_customize_manager/add_section/)
-
$section_id String If you did not specify a post_id, this will be the second argument to pass to get_field()
.
acf_add_customizer_section(array(
'title' => 'Some Post Meta',
'storage_type' => 'post',
));
// in the init hook
acf_add_customizer_section(array(
'title' => 'Mod the Theme',
'storage_type' => 'theme_mod',
'post_id' => 'acf_theme_mod',
));
// in your theme
the_field('acf_field_selector','acf_theme_mod');