-
Notifications
You must be signed in to change notification settings - Fork 8
Customizer
Ultimate fields makes Adding fields to the Customizer a piece of cake. Multiple locations in the plugin can not only show their fields in a standard place (ex. a meta box for the Post Type location), but can also display those fields in the customizer.
The Customizer location allows you to add custom fields solely to the customizer without showing them anywhere else in the dashboard.
To add fields to the customizer with the the Administration Interface, please follow these steps:
- If you are not on the "Add Container" screen already, locate the "Ultimate Fields" section in the administration area and click the "Add New" button on the top (next to the "Containers" title).
- Locate the "Locations" box.
- Click "Customizer" from the bottom row.
- Customize the settings for the customizer.
The customizer location in Ultimate Fields is handled by the Ultimate_Fields\Location\Customizer
class. In order to use it, you can either create the new location object manually or let the container do it for you.
The constructor of the class looks like this:
public function __construct( $args = array() ) {
$args
is an array, which allows you to set arguments without having to explicitly call the particular setter.
Create a new location by using the new
keyword and assign it to the container through the add_location()
method.
use Ultimate_Fields\Container;
use Ultimate_Fields\Location\Customizer;
$container = Container::create( 'theme-colors' );
// Create a new location and add definitions to it
$location = new Customizer();
// Once the location has been fully set up, add it to the container
$container->add_location( $location );
You can also let the container create the location for you by providing the "customizer" string as the first parameter to add_location()
.
use Ultimate_Fields\Container;
Container::create( 'theme-colors' )
->add_location( 'customizer' );
To retrieve the values of fields, associated with the Customizr location, $type
parameter of all *_value
functions should be "option"
.
Examples:
<?php
$background_color = get_option( 'background_color' );
Please read Adding fields to the Customizer to learn how to dynamically change values within the customizer preview without refresing the page.
The priority setting for customizer locations allows you to use a number to indicate where in the customizer menu you want to show the new setting. The default priority is 150, which shows the new section around the middle of the menu.
a field for the priority will be displayed in the location's settings.
you can either use the priority
parameter in the arguments array or use the set_priority
method.
// Argument
$container->add_location( 'customizer', array(
'priority' => 200
));
// Method
$location = new Ultimate_Fields\Location\Customizer();
$location->set_priority( 200 );
Please read the Displaying data in the front-end section to see what PostMessage fields are and how to use them.
Quick start
- Creating fields and using their values
- Installation
- Administration interface
- Using the PHP API
- Container Settings
Locations
- Overview & Usage
- Post Type
- Options Page
- Taxonomy
- Comment
- User
- Widget
- Shortcode
- Menu Item
- Attachment
- Customizer
Fields
- Fields
- Text
- Textarea
- WYSIWYG
- Password
- Checkbox
- Select
- Multiselect
- Image Select
- File
- Image
- Audio
- Video
- Gallery
- WP Object
- WP Objects
- Link
- Date
- DateTime
- Time
- Color
- Font
- Icon
- Map
- Embed
- Number
- Sidebar
- Complex
- Repeater
- Layout
- Section
- Tab
- Message
Features
- Adding fields to the Customizer
- Conditional Logic
- Front-End Forms
- Administration columns
- Import and Export
- REST API
- JSON Synchronization
- Yoast SEO
Ultimate Post Types
Functions and API
Tutorials