This members-only tutorial for intermediate to advanced users provides the steps to register a settings page in WordPress + Oxygen site using Meta Box, attach a custom fields group and display the field values conditionally.
Step 1 - Register a Settings page
Install and activate Meta Box.
Go to Meta Box > Settings Pages and click New Settings Page.
Give it a title of say, "Options". This is only for organizational purpose and won't be used in the code.
Select the gear (cog) icon.
Settings Page ID:
Step 2 - Register a field group
Let's create a field group for our settings page.
Go to Meta Box > Custom Fields and click Add New.
Give a title of say, "Sitewide".
Add your desired fields. In this example, we are going to add
logo- "Single Image" type of field
notice- "WYSIWYG Editor" type of field
button_background_color- "Color Picker" type of field
Set the field group to appear on the setting page created in the first step.
sitewide_ string we have set as the Field ID prefix.
This means we can keep the ID of our fields simple like
logo instead of
sitewide_logo when adding the fields. In a later step when it is time to refer to the field, we need to use
sitewide_logo even if the field ID appears as
logo in the interface.
Step 3 - Populate the field group
Click Options in the WP admin left menu and populate the fields.
Step 4 - Define functions to retrieve field values
Let us define a custom function to get the URL of logo image from the settings page so we can set this as Oxygen Image component's URL via dynamic data.
Install and activate Code Snippets plugin.
Go to Snippets > Add New.
Title: [Meta Box] Functions for getting Settings page field values
This is a premium members-only content.
To view the rest of the content, please sign up for membership ($47/month or $499 one-time).
Already a member? Log in below or here.