extends | title | group | prev | next | order |
---|---|---|---|---|---|
docs |
Integrating Advanced Custom Fields |
Extending |
adding-shortcodes |
child-theme-development |
1 |
Advanced Custom Fields plugin allows you to create user-friendly administration pages and custom fields.
Advanced Custom Fields initiation files may be easily blended into a current folder structure. It's recommended to create additional ACF/
directory inside Structure/
folder. You can hold there all components related to ACF (like creating fields schema and custom admin pages).
theme
├── app/
│ ├── Structure/
│ │ ├── ACF/ # — Directory for ACF components
│ │ │ ├── settings.php # — Theme settings page configuration file
Remember to add a file path of the new component to autoload list inside a configuration file.
'autoload' => [
//...
'Structure/ACF/settings.php',
//...
]
Let's create the settings page for our theme.
namespace Tonik\Theme\App\Structure\ACF;
use function Tonik\Theme\App\config;
acf_add_options_page([
'page_title' => __('Theme Settings', config('textdomain')),
'menu_title' => __('Theme Settings', config('textdomain')),
'menu_slug' => 'theme-settings',
'capability' => 'edit_posts',
'redirect' => false
]);