Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

ACF Field Groups

Harry Wiseman edited this page Apr 8, 2019 · 2 revisions

Nemesis provides helper functions to create custom Field Groups to be used either with Blocks or just as normal ACF groups.

Testimonial example

When adding fields for the Testimonial block you first need to create a class for this located in classes/ACF/FieldGroups you will need to extend the BaseFields class provided by Nemesis - this will then give you access to all the different field types you need.

<?php

namespace SiteName\Classes\ACF\FieldGroups;

use NanoSoup\Nemesis\ACF\BaseFields;

/**
 * Class CareersSettings
 * @package SiteName\ACF\FieldGroups
 */
class CareersSettings extends BaseFields
{
    /**
     *
     */
    public function __construct()
    {
        add_action('acf/init', [$this, 'registerFieldGroup']);
    }

    /**
     *
     */
    public function registerFieldGroup()
    {
        acf_add_local_field_group([
            'key' => 'group_careers_settings',
            'title' => 'Careers Attributes',
            'fields' => [
                $this->textarea('setting_icon', 'Snippet')
            ],
            'location' => [
                [
                    [
                        'param' => 'post_type',
                        'operator' => '==',
                        'value' => 'careers',
                    ]
                ]
            ],
            'menu_order' => 0,
            'position' => 'side',
            'style' => 'default',
            'label_placement' => 'top',
            'instruction_placement' => 'label',
            'hide_on_screen' => '',
            'active' => 1,
            'description' => '',
        ]);
    }
}

Clone this wiki locally